@nok-integration/storefront-react 0.29.4 → 0.29.6

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 CHANGED
@@ -6054,6 +6054,7 @@ declare interface ShopContextValue {
6054
6054
  subscribe: (listener: OnEvent) => () => void;
6055
6055
  navigate: (to: ShopRoute) => void;
6056
6056
  prefetch: ((to: ShopRoute) => void) | null;
6057
+ hasSession: () => Promise<boolean>;
6057
6058
  }
6058
6059
 
6059
6060
  export declare type ShopEvent = {
package/dist/index.mjs CHANGED
@@ -5749,6 +5749,14 @@ function DaznShopProvider({ children, ...config }) {
5749
5749
  const getTokenRef = useRef(getToken);
5750
5750
  getTokenRef.current = getToken;
5751
5751
  const stableGetToken = useCallback(() => getTokenRef.current(), []);
5752
+ const hasSession = useCallback(async () => {
5753
+ if (sessionTransport === "cookie") return true;
5754
+ try {
5755
+ return Boolean(await getTokenRef.current());
5756
+ } catch {
5757
+ return false;
5758
+ }
5759
+ }, [sessionTransport]);
5752
5760
  const productsRef = useRef(null);
5753
5761
  productsRef.current ??= new ProductCache();
5754
5762
  const products2 = productsRef.current;
@@ -5837,8 +5845,9 @@ function DaznShopProvider({ children, ...config }) {
5837
5845
  emit,
5838
5846
  subscribe,
5839
5847
  navigate,
5840
- prefetch: hostPrefetch ?? null
5841
- }), [api, market, products2, theme, resolvedFeatures, notifications, locale, assetBaseUrl, emit, subscribe, navigate, hostPrefetch]);
5848
+ prefetch: hostPrefetch ?? null,
5849
+ hasSession
5850
+ }), [api, market, products2, theme, resolvedFeatures, notifications, locale, assetBaseUrl, emit, subscribe, navigate, hostPrefetch, hasSession]);
5842
5851
  return jsx(ShopContext.Provider, {
5843
5852
  value: value2,
5844
5853
  children: jsx(CartCacheContext.Provider, {
@@ -6253,15 +6262,15 @@ const ShopSurface = forwardRef(function ShopSurface2({ tone, fill: fill2 = false
6253
6262
  children
6254
6263
  });
6255
6264
  });
6256
- const root$7 = "_root_ney0g_1";
6257
- const inner = "_inner_ney0g_6";
6258
- const media$5 = "_media_ney0g_20";
6259
- const lines$2 = "_lines_ney0g_32";
6260
- const lineWide = "_lineWide_ney0g_41";
6261
- const lineMid = "_lineMid_ney0g_45";
6262
- const lineNarrow = "_lineNarrow_ney0g_49";
6263
- const row$9 = "_row_ney0g_53";
6264
- const action$2 = "_action_ney0g_57";
6265
+ const root$7 = "_root_l5418_1";
6266
+ const inner = "_inner_l5418_6";
6267
+ const media$5 = "_media_l5418_20";
6268
+ const lines$2 = "_lines_l5418_32";
6269
+ const lineWide = "_lineWide_l5418_41";
6270
+ const lineMid = "_lineMid_l5418_45";
6271
+ const lineNarrow = "_lineNarrow_l5418_49";
6272
+ const row$9 = "_row_l5418_53";
6273
+ const action$2 = "_action_l5418_57";
6265
6274
  const styles$T = {
6266
6275
  root: root$7,
6267
6276
  inner,
@@ -6601,6 +6610,7 @@ function ScreenSkeleton({ tone, shape = "media" }) {
6601
6610
  tone,
6602
6611
  fill: true,
6603
6612
  className: styles$T.root,
6613
+ "data-shop-layout": "wide",
6604
6614
  children: jsx("div", {
6605
6615
  className: styles$T.inner,
6606
6616
  role: "status",
@@ -8083,9 +8093,9 @@ function ReturnItemsView({ order, onSubmit, busy = false }) {
8083
8093
  const t = useT();
8084
8094
  const wide2 = useDesktopLayout();
8085
8095
  useOrderNav([t("My orders"), t("Order #{0}", shortRef$1(order.order_ref))], t("Return items"));
8086
- const layout = wide2 ? {
8096
+ const layout = {
8087
8097
  "data-shop-layout": "wide"
8088
- } : {};
8098
+ };
8089
8099
  const pageClass = [styles$H.page, wide2 ? styles$H.wide : ""].join(" ");
8090
8100
  const returnable = useMemo(() => order.items.filter((i) => unitsLeft(i) > 0), [order.items]);
8091
8101
  const selected2 = Object.entries(chosen).filter(([, reason2]) => reason2 !== void 0);
@@ -8309,9 +8319,7 @@ function ReturnLabelView({ ret, onDone }) {
8309
8319
  useOrderNav([t("My orders"), t("Order #{0}", shortRef$1(ret.order_ref))], t("Return items"));
8310
8320
  return jsx("div", {
8311
8321
  className: [styles$G.page, wide2 ? styles$G.wide : ""].join(" "),
8312
- ...wide2 ? {
8313
- "data-shop-layout": "wide"
8314
- } : {},
8322
+ "data-shop-layout": "wide",
8315
8323
  children: jsxs("div", {
8316
8324
  className: styles$G.main,
8317
8325
  children: [jsxs("div", {
@@ -8457,9 +8465,7 @@ function ReturnTrackingView({ ret, locale: localeProp }) {
8457
8465
  fill: true,
8458
8466
  children: jsxs("div", {
8459
8467
  className: [styles$F.page, wide2 ? styles$F.wide : ""].join(" "),
8460
- ...wide2 ? {
8461
- "data-shop-layout": "wide"
8462
- } : {},
8468
+ "data-shop-layout": "wide",
8463
8469
  children: [jsxs("section", {
8464
8470
  className: styles$F.widget,
8465
8471
  "aria-labelledby": "return-title",
@@ -9207,9 +9213,7 @@ function OrderTrackingContent({ orderRef, locale: localeProp, onStartReturn, onO
9207
9213
  return jsxs("div", {
9208
9214
  className: [styles$D.page, wide2 ? styles$D.wide : "", wide2 && order.vip ? styles$D.vip : ""].join(" "),
9209
9215
  ref: cancelledPage,
9210
- ...wide2 ? {
9211
- "data-shop-layout": "wide"
9212
- } : {},
9216
+ "data-shop-layout": "wide",
9213
9217
  children: [jsxs("div", {
9214
9218
  className: styles$D.cancelledMain,
9215
9219
  children: [jsxs("div", {
@@ -9253,9 +9257,7 @@ function OrderTrackingContent({ orderRef, locale: localeProp, onStartReturn, onO
9253
9257
  }
9254
9258
  return jsxs("div", {
9255
9259
  className: [styles$D.page, wide2 ? styles$D.wide : ""].join(" "),
9256
- ...wide2 ? {
9257
- "data-shop-layout": "wide"
9258
- } : {},
9260
+ "data-shop-layout": "wide",
9259
9261
  children: [jsxs("section", {
9260
9262
  className: styles$D.widget,
9261
9263
  "aria-label": t("Delivery status"),
@@ -9475,9 +9477,7 @@ function OrderConfirmationContent({ orderRef, locale: localeProp, onDone }) {
9475
9477
  }
9476
9478
  return jsxs("div", {
9477
9479
  className: [styles$C.page, wide2 ? styles$C.wide : ""].join(" "),
9478
- ...wide2 ? {
9479
- "data-shop-layout": "wide"
9480
- } : {},
9480
+ "data-shop-layout": "wide",
9481
9481
  children: [jsxs("section", {
9482
9482
  className: styles$C.confirmed,
9483
9483
  "aria-label": t("Order confirmation"),
@@ -15008,7 +15008,7 @@ function heroFromProduct(product, ctaLabel) {
15008
15008
  function ActiveLanding({ token, invite, screen: screen2 }) {
15009
15009
  const t = useT();
15010
15010
  const toast2 = useToast();
15011
- const { api, emit } = useShop();
15011
+ const { api, emit, hasSession } = useShop();
15012
15012
  const navigate = useNavigate();
15013
15013
  const sku = invite.items[0]?.product_sku ?? "";
15014
15014
  const loaded = useProduct(sku, {
@@ -15021,7 +15021,21 @@ function ActiveLanding({ token, invite, screen: screen2 }) {
15021
15021
  else window.location.assign(to);
15022
15022
  }, [navigate]);
15023
15023
  const fallback = useMemo(() => loaded.product ? heroFromProduct(loaded.product, t("See more")) : null, [loaded.product, t]);
15024
+ const shop2 = useCallback(async () => {
15025
+ if (await hasSession()) go(productPath);
15026
+ else emit({
15027
+ type: "session_required",
15028
+ action: "vip_claim"
15029
+ });
15030
+ }, [emit, go, hasSession, productPath]);
15024
15031
  const claim = useCallback(async (variantSku) => {
15032
+ if (!await hasSession()) {
15033
+ emit({
15034
+ type: "session_required",
15035
+ action: "vip_claim"
15036
+ });
15037
+ return;
15038
+ }
15025
15039
  try {
15026
15040
  const current2 = await api.cart.get().catch(() => null);
15027
15041
  if (current2?.vip?.invite_ref === invite.invite_ref) {
@@ -15062,12 +15076,12 @@ function ActiveLanding({ token, invite, screen: screen2 }) {
15062
15076
  });
15063
15077
  toast2.show(t(treatmentFor(code).body), "critical");
15064
15078
  }
15065
- }, [api, emit, invite.invite_ref, t, toast2, token]);
15079
+ }, [api, emit, hasSession, invite.invite_ref, t, toast2, token]);
15066
15080
  if (screen2 === "hero") {
15067
15081
  const hero2 = invite.hero ?? fallback;
15068
15082
  if (hero2) return jsx(VipHero, {
15069
15083
  hero: hero2,
15070
- onContinue: () => go(productPath)
15084
+ onContinue: () => void shop2()
15071
15085
  });
15072
15086
  } else if (loaded.product) {
15073
15087
  return jsx(ProductDetail, {
@@ -5749,6 +5749,14 @@ function DaznShopProvider({ children, ...config }) {
5749
5749
  const getTokenRef = useRef(getToken);
5750
5750
  getTokenRef.current = getToken;
5751
5751
  const stableGetToken = useCallback(() => getTokenRef.current(), []);
5752
+ const hasSession = useCallback(async () => {
5753
+ if (sessionTransport === "cookie") return true;
5754
+ try {
5755
+ return Boolean(await getTokenRef.current());
5756
+ } catch {
5757
+ return false;
5758
+ }
5759
+ }, [sessionTransport]);
5752
5760
  const productsRef = useRef(null);
5753
5761
  productsRef.current ??= new ProductCache();
5754
5762
  const products2 = productsRef.current;
@@ -5837,8 +5845,9 @@ function DaznShopProvider({ children, ...config }) {
5837
5845
  emit,
5838
5846
  subscribe,
5839
5847
  navigate,
5840
- prefetch: hostPrefetch ?? null
5841
- }), [api, market, products2, theme, resolvedFeatures, notifications, locale, assetBaseUrl, emit, subscribe, navigate, hostPrefetch]);
5848
+ prefetch: hostPrefetch ?? null,
5849
+ hasSession
5850
+ }), [api, market, products2, theme, resolvedFeatures, notifications, locale, assetBaseUrl, emit, subscribe, navigate, hostPrefetch, hasSession]);
5842
5851
  return jsx(ShopContext.Provider, {
5843
5852
  value: value2,
5844
5853
  children: jsx(CartCacheContext.Provider, {
@@ -6253,15 +6262,15 @@ const ShopSurface = forwardRef(function ShopSurface2({ tone, fill: fill2 = false
6253
6262
  children
6254
6263
  });
6255
6264
  });
6256
- const root$7 = "_root_ney0g_1";
6257
- const inner = "_inner_ney0g_6";
6258
- const media$5 = "_media_ney0g_20";
6259
- const lines$2 = "_lines_ney0g_32";
6260
- const lineWide = "_lineWide_ney0g_41";
6261
- const lineMid = "_lineMid_ney0g_45";
6262
- const lineNarrow = "_lineNarrow_ney0g_49";
6263
- const row$9 = "_row_ney0g_53";
6264
- const action$2 = "_action_ney0g_57";
6265
+ const root$7 = "_root_l5418_1";
6266
+ const inner = "_inner_l5418_6";
6267
+ const media$5 = "_media_l5418_20";
6268
+ const lines$2 = "_lines_l5418_32";
6269
+ const lineWide = "_lineWide_l5418_41";
6270
+ const lineMid = "_lineMid_l5418_45";
6271
+ const lineNarrow = "_lineNarrow_l5418_49";
6272
+ const row$9 = "_row_l5418_53";
6273
+ const action$2 = "_action_l5418_57";
6265
6274
  const styles$T = {
6266
6275
  root: root$7,
6267
6276
  inner,
@@ -6601,6 +6610,7 @@ function ScreenSkeleton({ tone, shape = "media" }) {
6601
6610
  tone,
6602
6611
  fill: true,
6603
6612
  className: styles$T.root,
6613
+ "data-shop-layout": "wide",
6604
6614
  children: jsx("div", {
6605
6615
  className: styles$T.inner,
6606
6616
  role: "status",
@@ -8083,9 +8093,9 @@ function ReturnItemsView({ order, onSubmit, busy = false }) {
8083
8093
  const t = useT();
8084
8094
  const wide2 = useDesktopLayout();
8085
8095
  useOrderNav([t("My orders"), t("Order #{0}", shortRef$1(order.order_ref))], t("Return items"));
8086
- const layout = wide2 ? {
8096
+ const layout = {
8087
8097
  "data-shop-layout": "wide"
8088
- } : {};
8098
+ };
8089
8099
  const pageClass = [styles$H.page, wide2 ? styles$H.wide : ""].join(" ");
8090
8100
  const returnable = useMemo(() => order.items.filter((i) => unitsLeft(i) > 0), [order.items]);
8091
8101
  const selected2 = Object.entries(chosen).filter(([, reason2]) => reason2 !== void 0);
@@ -8309,9 +8319,7 @@ function ReturnLabelView({ ret, onDone }) {
8309
8319
  useOrderNav([t("My orders"), t("Order #{0}", shortRef$1(ret.order_ref))], t("Return items"));
8310
8320
  return jsx("div", {
8311
8321
  className: [styles$G.page, wide2 ? styles$G.wide : ""].join(" "),
8312
- ...wide2 ? {
8313
- "data-shop-layout": "wide"
8314
- } : {},
8322
+ "data-shop-layout": "wide",
8315
8323
  children: jsxs("div", {
8316
8324
  className: styles$G.main,
8317
8325
  children: [jsxs("div", {
@@ -8457,9 +8465,7 @@ function ReturnTrackingView({ ret, locale: localeProp }) {
8457
8465
  fill: true,
8458
8466
  children: jsxs("div", {
8459
8467
  className: [styles$F.page, wide2 ? styles$F.wide : ""].join(" "),
8460
- ...wide2 ? {
8461
- "data-shop-layout": "wide"
8462
- } : {},
8468
+ "data-shop-layout": "wide",
8463
8469
  children: [jsxs("section", {
8464
8470
  className: styles$F.widget,
8465
8471
  "aria-labelledby": "return-title",
@@ -9207,9 +9213,7 @@ function OrderTrackingContent({ orderRef, locale: localeProp, onStartReturn, onO
9207
9213
  return jsxs("div", {
9208
9214
  className: [styles$D.page, wide2 ? styles$D.wide : "", wide2 && order.vip ? styles$D.vip : ""].join(" "),
9209
9215
  ref: cancelledPage,
9210
- ...wide2 ? {
9211
- "data-shop-layout": "wide"
9212
- } : {},
9216
+ "data-shop-layout": "wide",
9213
9217
  children: [jsxs("div", {
9214
9218
  className: styles$D.cancelledMain,
9215
9219
  children: [jsxs("div", {
@@ -9253,9 +9257,7 @@ function OrderTrackingContent({ orderRef, locale: localeProp, onStartReturn, onO
9253
9257
  }
9254
9258
  return jsxs("div", {
9255
9259
  className: [styles$D.page, wide2 ? styles$D.wide : ""].join(" "),
9256
- ...wide2 ? {
9257
- "data-shop-layout": "wide"
9258
- } : {},
9260
+ "data-shop-layout": "wide",
9259
9261
  children: [jsxs("section", {
9260
9262
  className: styles$D.widget,
9261
9263
  "aria-label": t("Delivery status"),
@@ -9475,9 +9477,7 @@ function OrderConfirmationContent({ orderRef, locale: localeProp, onDone }) {
9475
9477
  }
9476
9478
  return jsxs("div", {
9477
9479
  className: [styles$C.page, wide2 ? styles$C.wide : ""].join(" "),
9478
- ...wide2 ? {
9479
- "data-shop-layout": "wide"
9480
- } : {},
9480
+ "data-shop-layout": "wide",
9481
9481
  children: [jsxs("section", {
9482
9482
  className: styles$C.confirmed,
9483
9483
  "aria-label": t("Order confirmation"),
@@ -15008,7 +15008,7 @@ function heroFromProduct(product, ctaLabel) {
15008
15008
  function ActiveLanding({ token, invite, screen: screen2 }) {
15009
15009
  const t = useT();
15010
15010
  const toast2 = useToast();
15011
- const { api, emit } = useShop();
15011
+ const { api, emit, hasSession } = useShop();
15012
15012
  const navigate = useNavigate();
15013
15013
  const sku = invite.items[0]?.product_sku ?? "";
15014
15014
  const loaded = useProduct(sku, {
@@ -15021,7 +15021,21 @@ function ActiveLanding({ token, invite, screen: screen2 }) {
15021
15021
  else window.location.assign(to);
15022
15022
  }, [navigate]);
15023
15023
  const fallback = useMemo(() => loaded.product ? heroFromProduct(loaded.product, t("See more")) : null, [loaded.product, t]);
15024
+ const shop2 = useCallback(async () => {
15025
+ if (await hasSession()) go(productPath);
15026
+ else emit({
15027
+ type: "session_required",
15028
+ action: "vip_claim"
15029
+ });
15030
+ }, [emit, go, hasSession, productPath]);
15024
15031
  const claim = useCallback(async (variantSku) => {
15032
+ if (!await hasSession()) {
15033
+ emit({
15034
+ type: "session_required",
15035
+ action: "vip_claim"
15036
+ });
15037
+ return;
15038
+ }
15025
15039
  try {
15026
15040
  const current2 = await api.cart.get().catch(() => null);
15027
15041
  if (current2?.vip?.invite_ref === invite.invite_ref) {
@@ -15062,12 +15076,12 @@ function ActiveLanding({ token, invite, screen: screen2 }) {
15062
15076
  });
15063
15077
  toast2.show(t(treatmentFor(code).body), "critical");
15064
15078
  }
15065
- }, [api, emit, invite.invite_ref, t, toast2, token]);
15079
+ }, [api, emit, hasSession, invite.invite_ref, t, toast2, token]);
15066
15080
  if (screen2 === "hero") {
15067
15081
  const hero2 = invite.hero ?? fallback;
15068
15082
  if (hero2) return jsx(VipHero, {
15069
15083
  hero: hero2,
15070
- onContinue: () => go(productPath)
15084
+ onContinue: () => void shop2()
15071
15085
  });
15072
15086
  } else if (loaded.product) {
15073
15087
  return jsx(ProductDetail, {
@@ -279,43 +279,56 @@
279
279
  scroll-behavior: auto !important;
280
280
  }
281
281
  }
282
- ._root_ney0g_1 {
282
+ ._root_l5418_1 {
283
283
  display: flex;
284
284
  flex-direction: column;
285
285
  }
286
- ._inner_ney0g_6 {
286
+ ._inner_l5418_6 {
287
287
  display: flex;
288
288
  flex-direction: column;
289
289
  gap: var(--space-16);
290
290
  padding-bottom: var(--space-24);
291
291
  }
292
- ._media_ney0g_20 {
292
+ ._media_l5418_20 {
293
293
  width: 100%;
294
294
  min-height: 320px;
295
295
  aspect-ratio: 4 / 5;
296
296
  border-radius: 0;
297
297
  }
298
- ._lines_ney0g_32 {
298
+ ._lines_l5418_32 {
299
299
  display: flex;
300
300
  flex-direction: column;
301
301
  gap: var(--space-12);
302
302
  padding: 0 var(--space-16);
303
303
  }
304
- ._lineWide_ney0g_41 {
304
+ ._lineWide_l5418_41 {
305
305
  width: 70%;
306
306
  }
307
- ._lineMid_ney0g_45 {
307
+ ._lineMid_l5418_45 {
308
308
  width: 45%;
309
309
  }
310
- ._lineNarrow_ney0g_49 {
310
+ ._lineNarrow_l5418_49 {
311
311
  width: 88%;
312
312
  }
313
- ._row_ney0g_53 {
313
+ ._row_l5418_53 {
314
314
  width: 100%;
315
315
  }
316
- ._action_ney0g_57 {
316
+ ._action_l5418_57 {
317
317
  margin: var(--space-8) var(--space-16) 0;
318
318
  }
319
+ @media (min-width: 1200px) {
320
+ ._media_l5418_20 {
321
+ min-height: 0;
322
+ aspect-ratio: auto;
323
+ height: calc(100vh - var(--shop-chrome-top, 0px) - 64px);
324
+ }
325
+ ._lines_l5418_32,
326
+ ._action_l5418_57 {
327
+ width: min(1088px, 100%);
328
+ margin-inline: auto;
329
+ padding: 0;
330
+ }
331
+ }
319
332
  ._root_ryf3q_6 {
320
333
  display: flex;
321
334
  flex-direction: column;
package/dist/styles.css CHANGED
@@ -279,43 +279,56 @@
279
279
  scroll-behavior: auto !important;
280
280
  }
281
281
  }
282
- ._root_ney0g_1 {
282
+ ._root_l5418_1 {
283
283
  display: flex;
284
284
  flex-direction: column;
285
285
  }
286
- ._inner_ney0g_6 {
286
+ ._inner_l5418_6 {
287
287
  display: flex;
288
288
  flex-direction: column;
289
289
  gap: var(--space-16);
290
290
  padding-bottom: var(--space-24);
291
291
  }
292
- ._media_ney0g_20 {
292
+ ._media_l5418_20 {
293
293
  width: 100%;
294
294
  min-height: 320px;
295
295
  aspect-ratio: 4 / 5;
296
296
  border-radius: 0;
297
297
  }
298
- ._lines_ney0g_32 {
298
+ ._lines_l5418_32 {
299
299
  display: flex;
300
300
  flex-direction: column;
301
301
  gap: var(--space-12);
302
302
  padding: 0 var(--space-16);
303
303
  }
304
- ._lineWide_ney0g_41 {
304
+ ._lineWide_l5418_41 {
305
305
  width: 70%;
306
306
  }
307
- ._lineMid_ney0g_45 {
307
+ ._lineMid_l5418_45 {
308
308
  width: 45%;
309
309
  }
310
- ._lineNarrow_ney0g_49 {
310
+ ._lineNarrow_l5418_49 {
311
311
  width: 88%;
312
312
  }
313
- ._row_ney0g_53 {
313
+ ._row_l5418_53 {
314
314
  width: 100%;
315
315
  }
316
- ._action_ney0g_57 {
316
+ ._action_l5418_57 {
317
317
  margin: var(--space-8) var(--space-16) 0;
318
318
  }
319
+ @media (min-width: 1200px) {
320
+ ._media_l5418_20 {
321
+ min-height: 0;
322
+ aspect-ratio: auto;
323
+ height: calc(100vh - var(--shop-chrome-top, 0px) - 64px);
324
+ }
325
+ ._lines_l5418_32,
326
+ ._action_l5418_57 {
327
+ width: min(1088px, 100%);
328
+ margin-inline: auto;
329
+ padding: 0;
330
+ }
331
+ }
319
332
  ._root_ryf3q_6 {
320
333
  display: flex;
321
334
  flex-direction: column;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nok-integration/storefront-react",
3
- "version": "0.29.4",
3
+ "version": "0.29.6",
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",