@disconetwork/shopify 0.0.11 → 0.0.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/{DiscoPrepurchaseThankYou-3hTT7PYy.js → DiscoPrepurchaseThankYou-Bp4WlM3S.js} +182 -525
- package/dist/DiscoPrepurchaseThankYou-Bp4WlM3S.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/internal.js +1 -1
- package/package.json +4 -4
- package/dist/DiscoPrepurchaseThankYou-3hTT7PYy.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "preact/hooks";
|
|
2
|
-
import {
|
|
2
|
+
import { createContext, createElement } from "preact";
|
|
3
3
|
import { cloneElement, createContext as createContext$1, createElement as createElement$1, isValidElement, useCallback as useCallback$1, useContext as useContext$1, useEffect as useEffect$1, useMemo as useMemo$1, useState as useState$1 } from "preact/compat";
|
|
4
4
|
import { withImpressionDedupe } from "@disconetwork/core";
|
|
5
|
-
import { Fragment
|
|
5
|
+
import { Fragment, jsx } from "preact/jsx-runtime";
|
|
6
6
|
import { INTERNAL_BASE_URL, InternalDiscoClient, parseScreens } from "@disconetwork/core/internal";
|
|
7
|
-
import { Fragment as Fragment$
|
|
7
|
+
import { Fragment as Fragment$1, jsx as jsx$1, jsxs } from "preact/jsx-runtime";
|
|
8
8
|
import { useApi, useApplyAttributeChange, useApplyCartLinesChange, useAttributeValues, useBillingAddress, useCartLines, useCheckoutToken, useCustomer, useDiscountCodes, useEmail, useExtensionEditor, useInstructions, useLocalizationCountry, usePurchasingCompany, useShippingAddress, useShop, useSubscription, useSubtotalAmount, useTotalAmount } from "@shopify/ui-extensions/checkout/preact";
|
|
9
9
|
import { useApi as useApi$1, useCartLines as useCartLines$1, useDiscountCodes as useDiscountCodes$1, useOrder, usePurchasingCompany as usePurchasingCompany$1, useShop as useShop$1, useSubscription as useSubscription$1, useTotalAmount as useTotalAmount$1 } from "@shopify/ui-extensions/customer-account/preact";
|
|
10
10
|
import { QueryClient, QueryClientProvider, useMutation, useQuery } from "@tanstack/preact-query";
|
|
@@ -289,7 +289,7 @@ const CardContainer = ({ children, ...rest }) => {
|
|
|
289
289
|
};
|
|
290
290
|
//#endregion
|
|
291
291
|
//#region src/components/RecommendationsWidget/RecommendationsWidgetSkeleton.tsx
|
|
292
|
-
const WIDE
|
|
292
|
+
const WIDE = "@container (inline-size > 450px)";
|
|
293
293
|
const TILE_COUNT = 4;
|
|
294
294
|
const Block = ({ blockSize }) => /* @__PURE__ */ jsx$1("s-box", {
|
|
295
295
|
blockSize,
|
|
@@ -309,10 +309,10 @@ const HeroOfferSkeleton = () => /* @__PURE__ */ jsx$1("s-box", {
|
|
|
309
309
|
gap: "small-200",
|
|
310
310
|
children: [/* @__PURE__ */ jsx$1("s-skeleton-paragraph", { content: "Exclusive offer from a brand you'll love" }), /* @__PURE__ */ jsx$1("s-skeleton-paragraph", { content: "Get a special discount on your next order" })]
|
|
311
311
|
}), /* @__PURE__ */ jsx$1("s-stack", {
|
|
312
|
-
direction: `${WIDE
|
|
312
|
+
direction: `${WIDE} inline, block`,
|
|
313
313
|
gap: "base",
|
|
314
314
|
children: [0, 1].map((index) => /* @__PURE__ */ jsx$1("s-box", {
|
|
315
|
-
inlineSize: `${WIDE
|
|
315
|
+
inlineSize: `${WIDE} 160px, 100%`,
|
|
316
316
|
children: /* @__PURE__ */ jsx$1(Block, { blockSize: "44px" })
|
|
317
317
|
}, index))
|
|
318
318
|
})]
|
|
@@ -361,7 +361,7 @@ const RecommendationsWidgetSkeleton = () => /* @__PURE__ */ jsx$1("s-box", {
|
|
|
361
361
|
//#region src/sdkIdentity.ts
|
|
362
362
|
const SDK_IDENTITY = {
|
|
363
363
|
name: "@disconetwork/shopify",
|
|
364
|
-
version: "0.0.
|
|
364
|
+
version: "0.0.12"
|
|
365
365
|
};
|
|
366
366
|
//#endregion
|
|
367
367
|
//#region ../react-shared/dist/sdk-internals.js
|
|
@@ -610,6 +610,30 @@ function useRecommendationsData() {
|
|
|
610
610
|
return ctx;
|
|
611
611
|
}
|
|
612
612
|
//#endregion
|
|
613
|
+
//#region src/hooks/useCustomization.ts
|
|
614
|
+
const CUSTOMIZATION_TYPE = {
|
|
615
|
+
CHECKOUT: "checkout",
|
|
616
|
+
UPFRONT: "upfront"
|
|
617
|
+
};
|
|
618
|
+
//#endregion
|
|
619
|
+
//#region src/hooks/useRecommendationsCustomization.tsx
|
|
620
|
+
const useRecommendationsCustomization = ({ type = CUSTOMIZATION_TYPE.CHECKOUT } = {}) => {
|
|
621
|
+
const customization = useRecommendationsData()?.publisherCustomization?.[type] || null;
|
|
622
|
+
const hasCustomization = (detail) => {
|
|
623
|
+
if (!customization || typeof customization !== "object" || !detail) return false;
|
|
624
|
+
return !!customization[detail];
|
|
625
|
+
};
|
|
626
|
+
const getCustomization = (detail) => {
|
|
627
|
+
if (!hasCustomization(detail) || !customization) return null;
|
|
628
|
+
return customization[detail];
|
|
629
|
+
};
|
|
630
|
+
const applyCustomizationOrFallback = (detail, fallback = null) => {
|
|
631
|
+
if (!hasCustomization(detail)) return fallback;
|
|
632
|
+
return getCustomization(detail);
|
|
633
|
+
};
|
|
634
|
+
return { applyCustomizationOrFallback };
|
|
635
|
+
};
|
|
636
|
+
//#endregion
|
|
613
637
|
//#region src/hooks/useCounter.tsx
|
|
614
638
|
const useCounter = ({ start = 0, min = 0, max = Infinity, resetOnMax = false, disabled = false } = {}) => {
|
|
615
639
|
const [counter, setCounter] = useState(start);
|
|
@@ -695,45 +719,6 @@ const useScrollableSlot = () => {
|
|
|
695
719
|
return context;
|
|
696
720
|
};
|
|
697
721
|
//#endregion
|
|
698
|
-
//#region src/hooks/useIdentity.tsx
|
|
699
|
-
const useIdentity = () => {
|
|
700
|
-
const data = useContext(UserContext);
|
|
701
|
-
if (!data) throw new Error("No wrapper User manager found");
|
|
702
|
-
return data;
|
|
703
|
-
};
|
|
704
|
-
//#endregion
|
|
705
|
-
//#region src/hooks/useCustomization.ts
|
|
706
|
-
const CUSTOMIZATION_TYPE = {
|
|
707
|
-
CHECKOUT: "checkout",
|
|
708
|
-
UPFRONT: "upfront"
|
|
709
|
-
};
|
|
710
|
-
//#endregion
|
|
711
|
-
//#region src/hooks/useRecommendationsCustomization.tsx
|
|
712
|
-
const useRecommendationsCustomization = ({ type = CUSTOMIZATION_TYPE.CHECKOUT } = {}) => {
|
|
713
|
-
const customization = useRecommendationsData()?.publisherCustomization?.[type] || null;
|
|
714
|
-
const hasCustomization = (detail) => {
|
|
715
|
-
if (!customization || typeof customization !== "object" || !detail) return false;
|
|
716
|
-
return !!customization[detail];
|
|
717
|
-
};
|
|
718
|
-
const getCustomization = (detail) => {
|
|
719
|
-
if (!hasCustomization(detail) || !customization) return null;
|
|
720
|
-
return customization[detail];
|
|
721
|
-
};
|
|
722
|
-
const applyCustomizationOrFallback = (detail, fallback = null) => {
|
|
723
|
-
if (!hasCustomization(detail)) return fallback;
|
|
724
|
-
return getCustomization(detail);
|
|
725
|
-
};
|
|
726
|
-
return { applyCustomizationOrFallback };
|
|
727
|
-
};
|
|
728
|
-
//#endregion
|
|
729
|
-
//#region src/components/RecommendationsWidget/useFirstOfferHeading.ts
|
|
730
|
-
const useFirstOfferHeading = () => {
|
|
731
|
-
const { user } = useIdentity();
|
|
732
|
-
const { applyCustomizationOrFallback } = useRecommendationsCustomization();
|
|
733
|
-
const firstName = user?.extrapolatedFirstName;
|
|
734
|
-
return applyCustomizationOrFallback("widget_heading", `${firstName ? `${firstName}, thank you` : "Thank you"} for your purchase:`);
|
|
735
|
-
};
|
|
736
|
-
//#endregion
|
|
737
722
|
//#region src/conf/env_conf.ts
|
|
738
723
|
const BUCKET_NAME = {
|
|
739
724
|
production: "coopcommerce",
|
|
@@ -818,6 +803,21 @@ function getImageVariants(imgUrl, dimensions) {
|
|
|
818
803
|
//#region src/hooks/useDiscoEnv.ts
|
|
819
804
|
const useDiscoEnv = () => useDiscoClient().env;
|
|
820
805
|
//#endregion
|
|
806
|
+
//#region src/hooks/useIdentity.tsx
|
|
807
|
+
const useIdentity = () => {
|
|
808
|
+
const data = useContext(UserContext);
|
|
809
|
+
if (!data) throw new Error("No wrapper User manager found");
|
|
810
|
+
return data;
|
|
811
|
+
};
|
|
812
|
+
//#endregion
|
|
813
|
+
//#region src/components/RecommendationsWidget/useFirstOfferHeading.ts
|
|
814
|
+
const useFirstOfferHeading = () => {
|
|
815
|
+
const { user } = useIdentity();
|
|
816
|
+
const { applyCustomizationOrFallback } = useRecommendationsCustomization();
|
|
817
|
+
const firstName = user?.extrapolatedFirstName;
|
|
818
|
+
return applyCustomizationOrFallback("widget_heading", `${firstName ? `${firstName}, thank you` : "Thank you"} for your purchase:`);
|
|
819
|
+
};
|
|
820
|
+
//#endregion
|
|
821
821
|
//#region src/components/Essential/generation/LinkGenerator.tsx
|
|
822
822
|
function InternalLink({ targetScreenId, children }) {
|
|
823
823
|
const ctx = useRendererContext();
|
|
@@ -868,29 +868,34 @@ const ScrollViewGenerator = { scrollview: ({ node, nodesToJSX }) => {
|
|
|
868
868
|
});
|
|
869
869
|
} };
|
|
870
870
|
//#endregion
|
|
871
|
-
//#region src/components/Essential/generation/TextGenerator.tsx
|
|
872
|
-
const TextGenerator = { text: ({ node }) => {
|
|
873
|
-
return node.text;
|
|
874
|
-
} };
|
|
875
|
-
//#endregion
|
|
876
871
|
//#region src/components/Essential/EssentialOfferContent.tsx
|
|
877
|
-
const renderers
|
|
878
|
-
|
|
872
|
+
const renderers = {
|
|
873
|
+
text: ({ node }) => {
|
|
874
|
+
return node.text;
|
|
875
|
+
},
|
|
879
876
|
...LinkGenerator,
|
|
880
877
|
...ParagraphGenerator,
|
|
881
878
|
...ScrollViewGenerator
|
|
882
879
|
};
|
|
883
|
-
const
|
|
880
|
+
const plainRenderers = {
|
|
881
|
+
...renderers,
|
|
882
|
+
...PlainParagraphGenerator
|
|
883
|
+
};
|
|
884
|
+
const EssentialOfferContent = ({ heading: offerHeading, subheading: offerSubheading, jsonContent: incentiveJson, plainBody = false }) => {
|
|
885
|
+
const fallbackText = offerSubheading || "";
|
|
884
886
|
return /* @__PURE__ */ jsxs("s-stack", {
|
|
885
887
|
gap: "small-200",
|
|
886
|
-
children: [/* @__PURE__ */ jsx$1("s-heading", { children: offerHeading }), /* @__PURE__ */ jsx$1(
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
children:
|
|
888
|
+
children: [/* @__PURE__ */ jsx$1("s-heading", { children: offerHeading }), /* @__PURE__ */ jsx$1("s-stack", {
|
|
889
|
+
gap: "small-200",
|
|
890
|
+
children: /* @__PURE__ */ jsx$1(ScreensRenderer, {
|
|
891
|
+
jsonContent: incentiveJson,
|
|
892
|
+
renderers: plainBody ? plainRenderers : renderers,
|
|
893
|
+
fallback: /* @__PURE__ */ jsx$1("s-paragraph", {
|
|
894
|
+
color: "subdued",
|
|
895
|
+
children: plainBody ? fallbackText : /* @__PURE__ */ jsx$1("s-text", {
|
|
896
|
+
type: "strong",
|
|
897
|
+
children: fallbackText
|
|
898
|
+
})
|
|
894
899
|
})
|
|
895
900
|
})
|
|
896
901
|
})]
|
|
@@ -898,11 +903,11 @@ const EssentialOfferContent = ({ heading: offerHeading, subheading: offerSubhead
|
|
|
898
903
|
};
|
|
899
904
|
//#endregion
|
|
900
905
|
//#region src/components/RecommendationsWidget/Essential/EssentialLayoutType.tsx
|
|
901
|
-
const EssentialLayoutType = ({ onLastOffer,
|
|
906
|
+
const EssentialLayoutType = ({ onLastOffer, plainBody, inlineButtons }) => {
|
|
902
907
|
const { isFirstOffer, activeRecommendation: recommendation } = useHeroOffer();
|
|
903
908
|
const renderBrandLogo = recommendation.offer.metadata.layoutType === "FEATURED_IMAGE";
|
|
904
909
|
return /* @__PURE__ */ jsx$1("s-query-container", { children: /* @__PURE__ */ jsx$1("s-box", {
|
|
905
|
-
padding:
|
|
910
|
+
padding: "base",
|
|
906
911
|
children: /* @__PURE__ */ jsxs("s-stack", {
|
|
907
912
|
gap: "small-400",
|
|
908
913
|
children: [
|
|
@@ -910,10 +915,10 @@ const EssentialLayoutType = ({ onLastOffer, compact }) => {
|
|
|
910
915
|
display: "@container (inline-size > 450px) none, auto",
|
|
911
916
|
children: /* @__PURE__ */ jsx$1("s-stack", {
|
|
912
917
|
alignItems: "center",
|
|
913
|
-
children: /* @__PURE__ */ jsx$1(AdvertiserLogo
|
|
918
|
+
children: /* @__PURE__ */ jsx$1(AdvertiserLogo, { recommendation })
|
|
914
919
|
})
|
|
915
920
|
}),
|
|
916
|
-
isFirstOffer &&
|
|
921
|
+
isFirstOffer && /* @__PURE__ */ jsx$1(FirstOfferHeading, {}),
|
|
917
922
|
/* @__PURE__ */ jsxs("s-grid", {
|
|
918
923
|
gridTemplateColumns: renderBrandLogo ? "@container (inline-size > 450px) 1fr auto, 1fr" : "1fr",
|
|
919
924
|
gap: "base",
|
|
@@ -923,8 +928,13 @@ const EssentialLayoutType = ({ onLastOffer, compact }) => {
|
|
|
923
928
|
children: [/* @__PURE__ */ jsx$1(EssentialOfferContent, {
|
|
924
929
|
heading: recommendation.offer.heading || "",
|
|
925
930
|
subheading: recommendation.offer.subheading || "",
|
|
926
|
-
jsonContent: recommendation.offer.jsonContent
|
|
927
|
-
|
|
931
|
+
jsonContent: recommendation.offer.jsonContent,
|
|
932
|
+
plainBody
|
|
933
|
+
}), inlineButtons ? /* @__PURE__ */ jsxs("s-grid", {
|
|
934
|
+
gridTemplateColumns: "@container (inline-size > 450px) auto auto 1fr, 1fr auto",
|
|
935
|
+
gap: "base",
|
|
936
|
+
children: [/* @__PURE__ */ jsx$1(PrimaryButton, {}), /* @__PURE__ */ jsx$1(SecondaryButton, { onLastOffer })]
|
|
937
|
+
}) : /* @__PURE__ */ jsxs("s-stack", {
|
|
928
938
|
direction: "@container (inline-size > 450px) inline, block",
|
|
929
939
|
gap: "base",
|
|
930
940
|
children: [/* @__PURE__ */ jsx$1("s-box", {
|
|
@@ -937,14 +947,14 @@ const EssentialLayoutType = ({ onLastOffer, compact }) => {
|
|
|
937
947
|
})]
|
|
938
948
|
}), renderBrandLogo && /* @__PURE__ */ jsx$1("s-box", {
|
|
939
949
|
display: "@container (inline-size > 450px) auto, none",
|
|
940
|
-
children: /* @__PURE__ */ jsx$1(AdvertiserLogo
|
|
950
|
+
children: /* @__PURE__ */ jsx$1(AdvertiserLogo, { recommendation })
|
|
941
951
|
})]
|
|
942
952
|
})
|
|
943
953
|
]
|
|
944
954
|
})
|
|
945
955
|
}) });
|
|
946
956
|
};
|
|
947
|
-
function AdvertiserLogo
|
|
957
|
+
function AdvertiserLogo({ recommendation }) {
|
|
948
958
|
const { advertiser } = recommendation;
|
|
949
959
|
const env = useDiscoEnv();
|
|
950
960
|
const imageSize = 140;
|
|
@@ -1023,155 +1033,10 @@ function FirstOfferHeading() {
|
|
|
1023
1033
|
});
|
|
1024
1034
|
}
|
|
1025
1035
|
//#endregion
|
|
1026
|
-
//#region src/components/RecommendationsWidget/DotIndicators.tsx
|
|
1027
|
-
const DotIndicators = ({ totalCount, activeIndex }) => {
|
|
1028
|
-
if (totalCount <= 1) return null;
|
|
1029
|
-
return /* @__PURE__ */ jsx$1("s-stack", {
|
|
1030
|
-
padding: "small-200 none",
|
|
1031
|
-
alignItems: "center",
|
|
1032
|
-
children: /* @__PURE__ */ jsx$1("s-stack", {
|
|
1033
|
-
direction: "inline",
|
|
1034
|
-
gap: "small-200",
|
|
1035
|
-
children: Array.from({ length: totalCount }, (_, i) => /* @__PURE__ */ jsx$1("s-badge", {
|
|
1036
|
-
size: "small",
|
|
1037
|
-
color: i === activeIndex ? "base" : "subdued",
|
|
1038
|
-
children: `${i + 1}`
|
|
1039
|
-
}, i))
|
|
1040
|
-
})
|
|
1041
|
-
});
|
|
1042
|
-
};
|
|
1043
|
-
//#endregion
|
|
1044
|
-
//#region src/conf/index.ts
|
|
1045
|
-
const getLeadGenRegisterUrl = (env) => `${INTERNAL_BASE_URL[env]}/lead_gen/register_lead/`;
|
|
1046
|
-
const PRIVACY_POLICY_URL = "https://www.disconetwork.com/privacy-policy";
|
|
1047
|
-
//#endregion
|
|
1048
|
-
//#region src/components/PrivacyLink.tsx
|
|
1049
|
-
const PrivacyLink = ({ onPress }) => {
|
|
1050
|
-
return /* @__PURE__ */ jsx$1("s-text", {
|
|
1051
|
-
color: "subdued",
|
|
1052
|
-
children: /* @__PURE__ */ jsx$1("s-link", {
|
|
1053
|
-
href: PRIVACY_POLICY_URL,
|
|
1054
|
-
target: "_blank",
|
|
1055
|
-
tone: "neutral",
|
|
1056
|
-
onClick: onPress,
|
|
1057
|
-
children: "Privacy Policy"
|
|
1058
|
-
})
|
|
1059
|
-
});
|
|
1060
|
-
};
|
|
1061
|
-
//#endregion
|
|
1062
|
-
//#region src/components/RecommendationsWidget/Footer.tsx
|
|
1063
|
-
function Footer() {
|
|
1064
|
-
const { track } = useEventTracker$1();
|
|
1065
|
-
const handlePrivacyClick = () => {
|
|
1066
|
-
track({
|
|
1067
|
-
type: "ELEMENT_CLICK",
|
|
1068
|
-
target: "INLINE_FOOTER_PRIVACY"
|
|
1069
|
-
});
|
|
1070
|
-
};
|
|
1071
|
-
return /* @__PURE__ */ jsx$1("s-stack", {
|
|
1072
|
-
padding: "small-200 base",
|
|
1073
|
-
alignItems: "end",
|
|
1074
|
-
children: /* @__PURE__ */ jsx$1(PrivacyLink, { onPress: handlePrivacyClick })
|
|
1075
|
-
});
|
|
1076
|
-
}
|
|
1077
|
-
//#endregion
|
|
1078
|
-
//#region src/components/RecommendationsWidget/Cover/index.tsx
|
|
1079
|
-
const CoverRecommendationsWidget = ({ heroRecommendationGroup }) => {
|
|
1080
|
-
const { track } = useEventTracker$1();
|
|
1081
|
-
useEffect(() => {
|
|
1082
|
-
track({ type: "WIDGET_LOAD" });
|
|
1083
|
-
}, [track]);
|
|
1084
|
-
return /* @__PURE__ */ jsx$1(HeroOfferProvider, {
|
|
1085
|
-
recommendationGroup: heroRecommendationGroup,
|
|
1086
|
-
loop: true,
|
|
1087
|
-
children: /* @__PURE__ */ jsx$1(CoverRecommendationsWidgetContent, {})
|
|
1088
|
-
});
|
|
1089
|
-
};
|
|
1090
|
-
const CoverRecommendationsWidgetContent = () => {
|
|
1091
|
-
const { track } = useEventTracker$1();
|
|
1092
|
-
const firstOfferHeading = useFirstOfferHeading();
|
|
1093
|
-
const modalHeading = typeof firstOfferHeading === "string" ? firstOfferHeading : "Your rewards";
|
|
1094
|
-
const { TOTAL_NUM_OFFERS, activeOfferIndex, nextOffer, activeRecommendation } = useHeroOffer();
|
|
1095
|
-
const [modalOpen, setModalOpen] = useState(false);
|
|
1096
|
-
const { insertionId, offer, advertiser } = activeRecommendation;
|
|
1097
|
-
useEffect(() => {
|
|
1098
|
-
if (!modalOpen) return;
|
|
1099
|
-
track({
|
|
1100
|
-
type: "BRAND_DISPLAY",
|
|
1101
|
-
target: "INLINE_SLOT",
|
|
1102
|
-
brand: {
|
|
1103
|
-
offerId: offer.id,
|
|
1104
|
-
advertiserId: advertiser.id,
|
|
1105
|
-
insertionId
|
|
1106
|
-
}
|
|
1107
|
-
});
|
|
1108
|
-
}, [
|
|
1109
|
-
modalOpen,
|
|
1110
|
-
track,
|
|
1111
|
-
insertionId,
|
|
1112
|
-
offer.id,
|
|
1113
|
-
advertiser.id
|
|
1114
|
-
]);
|
|
1115
|
-
const subtitle = `You've unlocked ${TOTAL_NUM_OFFERS} exclusive offer${TOTAL_NUM_OFFERS !== 1 ? "s" : ""} with your purchase — don't let them go to waste!`;
|
|
1116
|
-
return /* @__PURE__ */ jsx$1(CardContainer, {
|
|
1117
|
-
background: "transparent",
|
|
1118
|
-
children: /* @__PURE__ */ jsx$1("s-box", {
|
|
1119
|
-
padding: "base",
|
|
1120
|
-
children: /* @__PURE__ */ jsxs("s-stack", {
|
|
1121
|
-
gap: "base",
|
|
1122
|
-
children: [
|
|
1123
|
-
/* @__PURE__ */ jsx$1("s-heading", { children: "Your purchase comes with rewards!" }),
|
|
1124
|
-
/* @__PURE__ */ jsx$1("s-text", {
|
|
1125
|
-
color: "subdued",
|
|
1126
|
-
children: subtitle
|
|
1127
|
-
}),
|
|
1128
|
-
/* @__PURE__ */ jsx$1("s-button", {
|
|
1129
|
-
variant: "primary",
|
|
1130
|
-
command: "--show",
|
|
1131
|
-
commandFor: "cover-modal",
|
|
1132
|
-
onClick: () => track({
|
|
1133
|
-
type: "ELEMENT_CLICK",
|
|
1134
|
-
target: "OPEN_OVERLAY"
|
|
1135
|
-
}),
|
|
1136
|
-
children: "View my rewards"
|
|
1137
|
-
}),
|
|
1138
|
-
/* @__PURE__ */ jsxs("s-modal", {
|
|
1139
|
-
id: "cover-modal",
|
|
1140
|
-
padding: "base",
|
|
1141
|
-
heading: modalHeading,
|
|
1142
|
-
size: "large",
|
|
1143
|
-
onShow: () => {
|
|
1144
|
-
setModalOpen(true);
|
|
1145
|
-
track({ type: "WIDGET_DISPLAY" });
|
|
1146
|
-
},
|
|
1147
|
-
onHide: () => {
|
|
1148
|
-
setModalOpen(false);
|
|
1149
|
-
track({
|
|
1150
|
-
type: "ELEMENT_CLICK",
|
|
1151
|
-
target: "CLOSE_BUTTON"
|
|
1152
|
-
});
|
|
1153
|
-
},
|
|
1154
|
-
children: [
|
|
1155
|
-
/* @__PURE__ */ jsx$1(ScrollableSlotProvider, { children: /* @__PURE__ */ jsx$1(EssentialLayoutType, {
|
|
1156
|
-
onLastOffer: nextOffer,
|
|
1157
|
-
compact: true
|
|
1158
|
-
}) }),
|
|
1159
|
-
/* @__PURE__ */ jsx$1(DotIndicators, {
|
|
1160
|
-
totalCount: TOTAL_NUM_OFFERS,
|
|
1161
|
-
activeIndex: activeOfferIndex
|
|
1162
|
-
}),
|
|
1163
|
-
/* @__PURE__ */ jsx$1("s-divider", {}),
|
|
1164
|
-
/* @__PURE__ */ jsx$1(Footer, {})
|
|
1165
|
-
]
|
|
1166
|
-
})
|
|
1167
|
-
]
|
|
1168
|
-
})
|
|
1169
|
-
})
|
|
1170
|
-
});
|
|
1171
|
-
};
|
|
1172
|
-
//#endregion
|
|
1173
1036
|
//#region src/components/DiscoFeed/DiscoFeedProduct.tsx
|
|
1174
|
-
function ProductTile({ targetUrl, trackClick, image,
|
|
1037
|
+
function ProductTile({ targetUrl, trackClick, image, heading, subheading, splitHeading = false }) {
|
|
1038
|
+
const productName = `${heading} ${subheading}`;
|
|
1039
|
+
const altText = splitHeading ? subheading ? `${heading} ${subheading}` : heading : productName;
|
|
1175
1040
|
return /* @__PURE__ */ jsx$1("s-box", {
|
|
1176
1041
|
inlineSize: "100%",
|
|
1177
1042
|
children: /* @__PURE__ */ jsxs("s-stack", {
|
|
@@ -1188,18 +1053,37 @@ function ProductTile({ targetUrl, trackClick, image, productName }) {
|
|
|
1188
1053
|
aspectRatio: "1",
|
|
1189
1054
|
src: image.src,
|
|
1190
1055
|
srcSet: image.srcSet,
|
|
1191
|
-
alt:
|
|
1056
|
+
alt: altText,
|
|
1192
1057
|
inlineSize: "fill",
|
|
1193
1058
|
border: "base",
|
|
1194
1059
|
borderRadius: "small"
|
|
1195
1060
|
})
|
|
1196
1061
|
})
|
|
1197
1062
|
}), /* @__PURE__ */ jsx$1("s-stack", {
|
|
1198
|
-
maxBlockSize: "
|
|
1063
|
+
maxBlockSize: "64px",
|
|
1199
1064
|
maxInlineSize: "100%",
|
|
1200
1065
|
padding: "small-400 none none none",
|
|
1201
1066
|
overflow: "hidden",
|
|
1202
|
-
children: /* @__PURE__ */
|
|
1067
|
+
children: splitHeading ? /* @__PURE__ */ jsxs("s-stack", {
|
|
1068
|
+
gap: "small-500",
|
|
1069
|
+
children: [/* @__PURE__ */ jsx$1("s-paragraph", {
|
|
1070
|
+
tone: "info",
|
|
1071
|
+
children: /* @__PURE__ */ jsx$1("s-text", {
|
|
1072
|
+
type: "mark",
|
|
1073
|
+
children: /* @__PURE__ */ jsx$1("s-link", {
|
|
1074
|
+
target: "_blank",
|
|
1075
|
+
tone: "neutral",
|
|
1076
|
+
href: targetUrl,
|
|
1077
|
+
onClick: trackClick,
|
|
1078
|
+
children: heading
|
|
1079
|
+
})
|
|
1080
|
+
})
|
|
1081
|
+
}), subheading && /* @__PURE__ */ jsx$1("s-paragraph", {
|
|
1082
|
+
color: "subdued",
|
|
1083
|
+
tone: "success",
|
|
1084
|
+
children: subheading
|
|
1085
|
+
})]
|
|
1086
|
+
}) : /* @__PURE__ */ jsx$1("s-text", {
|
|
1203
1087
|
type: "strong",
|
|
1204
1088
|
color: "subdued",
|
|
1205
1089
|
children: /* @__PURE__ */ jsx$1("s-link", {
|
|
@@ -1218,13 +1102,14 @@ function ProductTile({ targetUrl, trackClick, image, productName }) {
|
|
|
1218
1102
|
//#region src/components/RecommendationsWidget/RecommendationsOfferRow.tsx
|
|
1219
1103
|
const PAGE_SIZE = 4;
|
|
1220
1104
|
const PRODUCT_IMAGE_SOURCE_SIZE = 256;
|
|
1221
|
-
const RecommendationsOfferRow = ({ recommendations, padding }) => {
|
|
1105
|
+
const RecommendationsOfferRow = ({ recommendations, padding, splitTileHeading }) => {
|
|
1222
1106
|
return /* @__PURE__ */ jsx$1(RecommendationsPager, {
|
|
1223
1107
|
recommendations: recommendations.filter((recommendation) => recommendation.offer.assets.length > 0),
|
|
1224
|
-
padding
|
|
1108
|
+
padding,
|
|
1109
|
+
splitTileHeading
|
|
1225
1110
|
});
|
|
1226
1111
|
};
|
|
1227
|
-
function RecommendationsPager({ recommendations, padding }) {
|
|
1112
|
+
function RecommendationsPager({ recommendations, padding, splitTileHeading }) {
|
|
1228
1113
|
const [page, setPage] = useState(0);
|
|
1229
1114
|
const pageCount = Math.ceil(recommendations.length / PAGE_SIZE);
|
|
1230
1115
|
const currentPage = Math.min(page, Math.max(pageCount - 1, 0));
|
|
@@ -1242,7 +1127,10 @@ function RecommendationsPager({ recommendations, padding }) {
|
|
|
1242
1127
|
gap: "small-200",
|
|
1243
1128
|
children: pageRecommendations.map((recommendation) => /* @__PURE__ */ jsx$1("s-box", {
|
|
1244
1129
|
inlineSize: "100%",
|
|
1245
|
-
children: /* @__PURE__ */ jsx$1(RecommendationsOfferRowTile, {
|
|
1130
|
+
children: /* @__PURE__ */ jsx$1(RecommendationsOfferRowTile, {
|
|
1131
|
+
recommendation,
|
|
1132
|
+
splitTileHeading
|
|
1133
|
+
})
|
|
1246
1134
|
}, recommendation.id))
|
|
1247
1135
|
}), pageCount > 1 && /* @__PURE__ */ jsxs("s-stack", {
|
|
1248
1136
|
direction: "inline",
|
|
@@ -1303,7 +1191,7 @@ function RecommendationsPager({ recommendations, padding }) {
|
|
|
1303
1191
|
})
|
|
1304
1192
|
});
|
|
1305
1193
|
}
|
|
1306
|
-
function RecommendationsOfferRowTile({ recommendation }) {
|
|
1194
|
+
function RecommendationsOfferRowTile({ recommendation, splitTileHeading }) {
|
|
1307
1195
|
const { track } = useEventTracker$1();
|
|
1308
1196
|
const env = useDiscoEnv();
|
|
1309
1197
|
const offerId = recommendation.offer.id;
|
|
@@ -1337,7 +1225,6 @@ function RecommendationsOfferRowTile({ recommendation }) {
|
|
|
1337
1225
|
});
|
|
1338
1226
|
};
|
|
1339
1227
|
const targetUrl = recommendation.offer.targetUrl;
|
|
1340
|
-
const productName = `${recommendation.offer.heading} ${recommendation.offer.subheading}`;
|
|
1341
1228
|
const offerImageAsset = recommendation.offer.assets[0];
|
|
1342
1229
|
if (!offerImageAsset) return null;
|
|
1343
1230
|
return /* @__PURE__ */ jsx$1(ProductTile, {
|
|
@@ -1347,12 +1234,48 @@ function RecommendationsOfferRowTile({ recommendation }) {
|
|
|
1347
1234
|
env,
|
|
1348
1235
|
size: PRODUCT_IMAGE_SOURCE_SIZE
|
|
1349
1236
|
}),
|
|
1350
|
-
|
|
1237
|
+
heading: recommendation.offer.heading,
|
|
1238
|
+
subheading: recommendation.offer.subheading,
|
|
1239
|
+
splitHeading: splitTileHeading
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
//#endregion
|
|
1243
|
+
//#region src/conf/index.ts
|
|
1244
|
+
const getLeadGenRegisterUrl = (env) => `${INTERNAL_BASE_URL[env]}/lead_gen/register_lead/`;
|
|
1245
|
+
const PRIVACY_POLICY_URL = "https://www.disconetwork.com/privacy-policy";
|
|
1246
|
+
//#endregion
|
|
1247
|
+
//#region src/components/PrivacyLink.tsx
|
|
1248
|
+
const PrivacyLink = ({ onPress }) => {
|
|
1249
|
+
return /* @__PURE__ */ jsx$1("s-text", {
|
|
1250
|
+
color: "subdued",
|
|
1251
|
+
children: /* @__PURE__ */ jsx$1("s-link", {
|
|
1252
|
+
href: PRIVACY_POLICY_URL,
|
|
1253
|
+
target: "_blank",
|
|
1254
|
+
tone: "neutral",
|
|
1255
|
+
onClick: onPress,
|
|
1256
|
+
children: "Privacy Policy"
|
|
1257
|
+
})
|
|
1258
|
+
});
|
|
1259
|
+
};
|
|
1260
|
+
//#endregion
|
|
1261
|
+
//#region src/components/RecommendationsWidget/Footer.tsx
|
|
1262
|
+
function Footer() {
|
|
1263
|
+
const { track } = useEventTracker$1();
|
|
1264
|
+
const handlePrivacyClick = () => {
|
|
1265
|
+
track({
|
|
1266
|
+
type: "ELEMENT_CLICK",
|
|
1267
|
+
target: "INLINE_FOOTER_PRIVACY"
|
|
1268
|
+
});
|
|
1269
|
+
};
|
|
1270
|
+
return /* @__PURE__ */ jsx$1("s-stack", {
|
|
1271
|
+
padding: "small-200 base",
|
|
1272
|
+
alignItems: "end",
|
|
1273
|
+
children: /* @__PURE__ */ jsx$1(PrivacyLink, { onPress: handlePrivacyClick })
|
|
1351
1274
|
});
|
|
1352
1275
|
}
|
|
1353
1276
|
//#endregion
|
|
1354
1277
|
//#region src/components/RecommendationsWidget/Essential/index.tsx
|
|
1355
|
-
const EssentialRecommendationsWidget = ({ heroRecommendationGroup, scrollableRecommendationGroup }) => {
|
|
1278
|
+
const EssentialRecommendationsWidget = ({ heroRecommendationGroup, scrollableRecommendationGroup, layoutOptions }) => {
|
|
1356
1279
|
const [showOfferSlot, setShowOfferSlot] = useState(!!heroRecommendationGroup);
|
|
1357
1280
|
const { track } = useEventTracker$1();
|
|
1358
1281
|
const { applyCustomizationOrFallback } = useRecommendationsCustomization();
|
|
@@ -1373,7 +1296,10 @@ const EssentialRecommendationsWidget = ({ heroRecommendationGroup, scrollableRec
|
|
|
1373
1296
|
borderWidth: "none none base none",
|
|
1374
1297
|
children: /* @__PURE__ */ jsx$1(HeroOfferProvider, {
|
|
1375
1298
|
recommendationGroup: heroRecommendationGroup,
|
|
1376
|
-
children: /* @__PURE__ */ jsx$1(TrackedEssentialLayout, {
|
|
1299
|
+
children: /* @__PURE__ */ jsx$1(TrackedEssentialLayout, {
|
|
1300
|
+
onLastOffer: hideOfferSlot,
|
|
1301
|
+
layoutOptions: layoutOptions?.hero
|
|
1302
|
+
})
|
|
1377
1303
|
})
|
|
1378
1304
|
}) : /* @__PURE__ */ jsx$1("s-box", {
|
|
1379
1305
|
padding: "base base none base",
|
|
@@ -1385,7 +1311,8 @@ const EssentialRecommendationsWidget = ({ heroRecommendationGroup, scrollableRec
|
|
|
1385
1311
|
borderWidth: "none none base none",
|
|
1386
1312
|
children: /* @__PURE__ */ jsx$1(RecommendationsOfferRow, {
|
|
1387
1313
|
recommendations: scrollableRecommendationGroup.recommendations,
|
|
1388
|
-
padding: "none base"
|
|
1314
|
+
padding: "none base",
|
|
1315
|
+
...layoutOptions?.scrollable
|
|
1389
1316
|
})
|
|
1390
1317
|
}),
|
|
1391
1318
|
/* @__PURE__ */ jsx$1(Footer, {})
|
|
@@ -1393,7 +1320,7 @@ const EssentialRecommendationsWidget = ({ heroRecommendationGroup, scrollableRec
|
|
|
1393
1320
|
})
|
|
1394
1321
|
});
|
|
1395
1322
|
};
|
|
1396
|
-
const TrackedEssentialLayout = ({ onLastOffer }) => {
|
|
1323
|
+
const TrackedEssentialLayout = ({ onLastOffer, layoutOptions }) => {
|
|
1397
1324
|
const { track } = useEventTracker$1();
|
|
1398
1325
|
const { activeRecommendation } = useHeroOffer();
|
|
1399
1326
|
const { insertionId, offer, advertiser } = activeRecommendation;
|
|
@@ -1413,283 +1340,11 @@ const TrackedEssentialLayout = ({ onLastOffer }) => {
|
|
|
1413
1340
|
offer.id,
|
|
1414
1341
|
advertiser.id
|
|
1415
1342
|
]);
|
|
1416
|
-
return /* @__PURE__ */ jsx$1(EssentialLayoutType, {
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
//#region src/components/RecommendationsWidget/EssentialList/EssentialListOfferBody.tsx
|
|
1420
|
-
const renderers = {
|
|
1421
|
-
...TextGenerator,
|
|
1422
|
-
...LinkGenerator,
|
|
1423
|
-
...PlainParagraphGenerator,
|
|
1424
|
-
...ScrollViewGenerator
|
|
1425
|
-
};
|
|
1426
|
-
/**
|
|
1427
|
-
* The offer's rich `jsonContent` in regular-weight, subdued paragraphs, or
|
|
1428
|
-
* `fallback` when the offer has none.
|
|
1429
|
-
*
|
|
1430
|
-
* The content sits in its own stack because switching screens (an internal
|
|
1431
|
-
* link) replaces every node in it, and the checkout host can append the
|
|
1432
|
-
* replacements to the end of their parent. Without a parent of their own they
|
|
1433
|
-
* would land after the CTA that follows the body on narrow containers.
|
|
1434
|
-
*/
|
|
1435
|
-
const EssentialListOfferBody = ({ jsonContent, fallback }) => /* @__PURE__ */ jsx$1("s-stack", {
|
|
1436
|
-
gap: "small-200",
|
|
1437
|
-
children: /* @__PURE__ */ jsx$1(ScreensRenderer, {
|
|
1438
|
-
jsonContent,
|
|
1439
|
-
renderers,
|
|
1440
|
-
fallback
|
|
1441
|
-
})
|
|
1442
|
-
});
|
|
1443
|
-
/** Container query prefix for the wide (side-by-side CTA) row layout. */
|
|
1444
|
-
const WIDE = "@container (inline-size > 450px)";
|
|
1445
|
-
//#endregion
|
|
1446
|
-
//#region src/components/RecommendationsWidget/EssentialList/EssentialListOfferRow.tsx
|
|
1447
|
-
const LOGO_SIZE = 56;
|
|
1448
|
-
/**
|
|
1449
|
-
* One offer in the list: brand logo, brand name, offer heading and body, and
|
|
1450
|
-
* a CTA that sits beside the copy on wide containers and below it on narrow
|
|
1451
|
-
* ones.
|
|
1452
|
-
*/
|
|
1453
|
-
const EssentialListOfferRow = ({ recommendation }) => {
|
|
1454
|
-
const { track } = useEventTracker$1();
|
|
1455
|
-
const { offer, advertiser, insertionId } = recommendation;
|
|
1456
|
-
useEffect(() => {
|
|
1457
|
-
track({
|
|
1458
|
-
type: "BRAND_DISPLAY",
|
|
1459
|
-
target: "INLINE_SLOT",
|
|
1460
|
-
brand: {
|
|
1461
|
-
offerId: offer.id,
|
|
1462
|
-
advertiserId: advertiser.id,
|
|
1463
|
-
insertionId
|
|
1464
|
-
}
|
|
1465
|
-
});
|
|
1466
|
-
}, [
|
|
1467
|
-
track,
|
|
1468
|
-
insertionId,
|
|
1469
|
-
offer.id,
|
|
1470
|
-
advertiser.id
|
|
1471
|
-
]);
|
|
1472
|
-
return /* @__PURE__ */ jsxs("s-grid", {
|
|
1473
|
-
gridTemplateColumns: `${WIDE} ${LOGO_SIZE}px 1fr auto, ${LOGO_SIZE}px 1fr`,
|
|
1474
|
-
gap: "base",
|
|
1475
|
-
alignItems: "start",
|
|
1476
|
-
children: [
|
|
1477
|
-
/* @__PURE__ */ jsx$1(AdvertiserLogo, { recommendation }),
|
|
1478
|
-
/* @__PURE__ */ jsxs("s-stack", {
|
|
1479
|
-
gap: "small-200",
|
|
1480
|
-
children: [
|
|
1481
|
-
/* @__PURE__ */ jsxs("s-stack", {
|
|
1482
|
-
gap: "none",
|
|
1483
|
-
children: [/* @__PURE__ */ jsx$1("s-text", {
|
|
1484
|
-
color: "subdued",
|
|
1485
|
-
children: advertiser.name
|
|
1486
|
-
}), /* @__PURE__ */ jsx$1("s-heading", { children: offer.heading })]
|
|
1487
|
-
}),
|
|
1488
|
-
/* @__PURE__ */ jsx$1(EssentialListOfferBody, {
|
|
1489
|
-
jsonContent: offer.jsonContent,
|
|
1490
|
-
fallback: /* @__PURE__ */ jsx$1(OfferBodyFallback, { recommendation })
|
|
1491
|
-
}),
|
|
1492
|
-
/* @__PURE__ */ jsx$1("s-box", {
|
|
1493
|
-
display: `${WIDE} none, auto`,
|
|
1494
|
-
children: /* @__PURE__ */ jsx$1(OfferCta, {
|
|
1495
|
-
recommendation,
|
|
1496
|
-
inlineSize: "fill"
|
|
1497
|
-
})
|
|
1498
|
-
})
|
|
1499
|
-
]
|
|
1500
|
-
}),
|
|
1501
|
-
/* @__PURE__ */ jsx$1("s-box", {
|
|
1502
|
-
display: `${WIDE} auto, none`,
|
|
1503
|
-
children: /* @__PURE__ */ jsx$1(OfferCta, {
|
|
1504
|
-
recommendation,
|
|
1505
|
-
inlineSize: "auto"
|
|
1506
|
-
})
|
|
1507
|
-
})
|
|
1508
|
-
]
|
|
1343
|
+
return /* @__PURE__ */ jsx$1(EssentialLayoutType, {
|
|
1344
|
+
onLastOffer,
|
|
1345
|
+
...layoutOptions
|
|
1509
1346
|
});
|
|
1510
1347
|
};
|
|
1511
|
-
/** Subheading plus the disclosure link, for offers without `jsonContent`. */
|
|
1512
|
-
function OfferBodyFallback({ recommendation }) {
|
|
1513
|
-
const { subheading, disclosureDetails } = recommendation.offer;
|
|
1514
|
-
const disclosureUrl = disclosureDetails?.targetUrl;
|
|
1515
|
-
return /* @__PURE__ */ jsxs("s-stack", {
|
|
1516
|
-
gap: "small-200",
|
|
1517
|
-
children: [subheading && /* @__PURE__ */ jsx$1("s-paragraph", {
|
|
1518
|
-
color: "subdued",
|
|
1519
|
-
children: subheading
|
|
1520
|
-
}), disclosureDetails && disclosureUrl && /* @__PURE__ */ jsx$1("s-text", {
|
|
1521
|
-
color: "subdued",
|
|
1522
|
-
children: /* @__PURE__ */ jsx$1("s-link", {
|
|
1523
|
-
href: disclosureUrl,
|
|
1524
|
-
target: "_blank",
|
|
1525
|
-
tone: "neutral",
|
|
1526
|
-
children: disclosureDetails.copy
|
|
1527
|
-
})
|
|
1528
|
-
})]
|
|
1529
|
-
});
|
|
1530
|
-
}
|
|
1531
|
-
function OfferCta({ recommendation, inlineSize }) {
|
|
1532
|
-
const { track } = useEventTracker$1();
|
|
1533
|
-
const { offer, advertiser, insertionId } = recommendation;
|
|
1534
|
-
const handleClick = () => {
|
|
1535
|
-
track({
|
|
1536
|
-
type: "BRAND_CLICK",
|
|
1537
|
-
target: "INLINE_ACTION_BUTTON",
|
|
1538
|
-
brand: {
|
|
1539
|
-
offerId: offer.id,
|
|
1540
|
-
advertiserId: advertiser.id,
|
|
1541
|
-
insertionId
|
|
1542
|
-
}
|
|
1543
|
-
});
|
|
1544
|
-
};
|
|
1545
|
-
return /* @__PURE__ */ jsx$1("s-button", {
|
|
1546
|
-
href: offer.targetUrl,
|
|
1547
|
-
target: "_blank",
|
|
1548
|
-
variant: "secondary",
|
|
1549
|
-
inlineSize,
|
|
1550
|
-
onClick: handleClick,
|
|
1551
|
-
children: /* @__PURE__ */ jsxs("s-stack", {
|
|
1552
|
-
direction: "inline",
|
|
1553
|
-
gap: "small-300",
|
|
1554
|
-
alignItems: "center",
|
|
1555
|
-
children: [offer.ctaDetails.acceptCopy, /* @__PURE__ */ jsx$1("s-icon", { type: "external" })]
|
|
1556
|
-
})
|
|
1557
|
-
});
|
|
1558
|
-
}
|
|
1559
|
-
function AdvertiserLogo({ recommendation }) {
|
|
1560
|
-
const { advertiser } = recommendation;
|
|
1561
|
-
const env = useDiscoEnv();
|
|
1562
|
-
const image = getImageSources(advertiser.logoUrl, {
|
|
1563
|
-
env,
|
|
1564
|
-
size: LOGO_SIZE * 2
|
|
1565
|
-
});
|
|
1566
|
-
return /* @__PURE__ */ jsx$1("s-box", {
|
|
1567
|
-
inlineSize: `${LOGO_SIZE}px`,
|
|
1568
|
-
blockSize: `${LOGO_SIZE}px`,
|
|
1569
|
-
border: "base",
|
|
1570
|
-
borderRadius: "base",
|
|
1571
|
-
overflow: "hidden",
|
|
1572
|
-
children: /* @__PURE__ */ jsx$1("s-image", {
|
|
1573
|
-
aspectRatio: "1",
|
|
1574
|
-
objectFit: "contain",
|
|
1575
|
-
src: image.src,
|
|
1576
|
-
srcSet: image.srcSet,
|
|
1577
|
-
alt: `${advertiser.name} logo`,
|
|
1578
|
-
inlineSize: "fill"
|
|
1579
|
-
})
|
|
1580
|
-
});
|
|
1581
|
-
}
|
|
1582
|
-
//#endregion
|
|
1583
|
-
//#region src/components/RecommendationsWidget/EssentialList/EssentialListPager.tsx
|
|
1584
|
-
const EssentialListPager = ({ page, pageCount, onPrevious, onNext }) => {
|
|
1585
|
-
if (pageCount <= 1) return null;
|
|
1586
|
-
const isFirstPage = page === 0;
|
|
1587
|
-
const isLastPage = page === pageCount - 1;
|
|
1588
|
-
return /* @__PURE__ */ jsxs("s-stack", {
|
|
1589
|
-
direction: "inline",
|
|
1590
|
-
alignItems: "center",
|
|
1591
|
-
gap: "small-200",
|
|
1592
|
-
children: [
|
|
1593
|
-
/* @__PURE__ */ jsx$1(PagerButton, {
|
|
1594
|
-
icon: "chevron-left",
|
|
1595
|
-
label: "Previous offers",
|
|
1596
|
-
disabled: isFirstPage,
|
|
1597
|
-
onClick: onPrevious
|
|
1598
|
-
}),
|
|
1599
|
-
/* @__PURE__ */ jsx$1("s-text", {
|
|
1600
|
-
color: "subdued",
|
|
1601
|
-
children: `${page + 1} / ${pageCount}`
|
|
1602
|
-
}),
|
|
1603
|
-
/* @__PURE__ */ jsx$1(PagerButton, {
|
|
1604
|
-
icon: "chevron-right",
|
|
1605
|
-
label: "Next offers",
|
|
1606
|
-
disabled: isLastPage,
|
|
1607
|
-
onClick: onNext
|
|
1608
|
-
})
|
|
1609
|
-
]
|
|
1610
|
-
});
|
|
1611
|
-
};
|
|
1612
|
-
function PagerButton({ icon, label, disabled, onClick }) {
|
|
1613
|
-
return /* @__PURE__ */ jsx$1("s-clickable", {
|
|
1614
|
-
accessibilityLabel: label,
|
|
1615
|
-
disabled,
|
|
1616
|
-
inlineSize: "32px",
|
|
1617
|
-
blockSize: "32px",
|
|
1618
|
-
borderRadius: "base",
|
|
1619
|
-
onClick,
|
|
1620
|
-
children: /* @__PURE__ */ jsx$1("s-stack", {
|
|
1621
|
-
blockSize: "100%",
|
|
1622
|
-
alignItems: "center",
|
|
1623
|
-
justifyContent: "center",
|
|
1624
|
-
children: /* @__PURE__ */ jsx$1("s-icon", {
|
|
1625
|
-
type: icon,
|
|
1626
|
-
size: "small",
|
|
1627
|
-
tone: disabled ? "neutral" : "auto"
|
|
1628
|
-
})
|
|
1629
|
-
})
|
|
1630
|
-
});
|
|
1631
|
-
}
|
|
1632
|
-
//#endregion
|
|
1633
|
-
//#region src/components/RecommendationsWidget/EssentialList/index.tsx
|
|
1634
|
-
/**
|
|
1635
|
-
* Essential list layout: the hero offers stacked as rows, a page at a time,
|
|
1636
|
-
* with a pager beside the heading.
|
|
1637
|
-
*/
|
|
1638
|
-
const EssentialListRecommendationsWidget = ({ heroRecommendationGroup }) => {
|
|
1639
|
-
const { track } = useEventTracker$1();
|
|
1640
|
-
const [page, setPage] = useState(0);
|
|
1641
|
-
useEffect(() => {
|
|
1642
|
-
track({ type: "WIDGET_LOAD" });
|
|
1643
|
-
track({ type: "WIDGET_DISPLAY" });
|
|
1644
|
-
}, [track]);
|
|
1645
|
-
const { recommendations } = heroRecommendationGroup;
|
|
1646
|
-
const pageCount = Math.ceil(recommendations.length / 2);
|
|
1647
|
-
const currentPage = Math.min(page, Math.max(pageCount - 1, 0));
|
|
1648
|
-
const pageRecommendations = recommendations.slice(currentPage * 2, (currentPage + 1) * 2);
|
|
1649
|
-
const firstRecommendation = pageRecommendations[0];
|
|
1650
|
-
if (!firstRecommendation) return null;
|
|
1651
|
-
const goToPage = (nextPage) => {
|
|
1652
|
-
const { offer, advertiser, insertionId } = firstRecommendation;
|
|
1653
|
-
track({
|
|
1654
|
-
type: "ELEMENT_CLICK",
|
|
1655
|
-
target: nextPage > currentPage ? "EXPLICIT_NAV_FORWARD" : "EXPLICIT_NAV_BACKWARD",
|
|
1656
|
-
brand: {
|
|
1657
|
-
offerId: offer.id,
|
|
1658
|
-
advertiserId: advertiser.id,
|
|
1659
|
-
insertionId
|
|
1660
|
-
}
|
|
1661
|
-
});
|
|
1662
|
-
setPage(nextPage);
|
|
1663
|
-
};
|
|
1664
|
-
return /* @__PURE__ */ jsxs(CardContainer, {
|
|
1665
|
-
background: "base",
|
|
1666
|
-
children: [
|
|
1667
|
-
/* @__PURE__ */ jsx$1("s-query-container", { children: /* @__PURE__ */ jsxs("s-stack", {
|
|
1668
|
-
padding: "base",
|
|
1669
|
-
gap: "base",
|
|
1670
|
-
children: [/* @__PURE__ */ jsxs("s-grid", {
|
|
1671
|
-
gridTemplateColumns: "1fr auto",
|
|
1672
|
-
gap: "base",
|
|
1673
|
-
alignItems: "center",
|
|
1674
|
-
children: [/* @__PURE__ */ jsx$1("s-heading", { children: /* @__PURE__ */ jsx$1(EssentialListHeading, {}) }), /* @__PURE__ */ jsx$1(EssentialListPager, {
|
|
1675
|
-
page: currentPage,
|
|
1676
|
-
pageCount,
|
|
1677
|
-
onPrevious: () => goToPage(currentPage - 1),
|
|
1678
|
-
onNext: () => goToPage(currentPage + 1)
|
|
1679
|
-
})]
|
|
1680
|
-
}), pageRecommendations.map((recommendation) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx$1("s-divider", {}), /* @__PURE__ */ jsx$1(EssentialListOfferRow, { recommendation })] }, recommendation.id))]
|
|
1681
|
-
}) }),
|
|
1682
|
-
/* @__PURE__ */ jsx$1("s-divider", {}),
|
|
1683
|
-
/* @__PURE__ */ jsx$1(Footer, {})
|
|
1684
|
-
]
|
|
1685
|
-
});
|
|
1686
|
-
};
|
|
1687
|
-
function EssentialListHeading() {
|
|
1688
|
-
const { user } = useIdentity();
|
|
1689
|
-
const { applyCustomizationOrFallback } = useRecommendationsCustomization();
|
|
1690
|
-
const firstName = user?.extrapolatedFirstName;
|
|
1691
|
-
return applyCustomizationOrFallback("widget_heading", firstName ? `${firstName}, you’ve unlocked exclusive offers.` : "You’ve unlocked exclusive offers.");
|
|
1692
|
-
}
|
|
1693
1348
|
//#endregion
|
|
1694
1349
|
//#region src/components/RecommendationsWidget/LeadGen/LeadGenHeader.tsx
|
|
1695
1350
|
const LeadGenHeader = () => {
|
|
@@ -2000,7 +1655,7 @@ function LeadGenActionOffer() {
|
|
|
2000
1655
|
const { activeRecommendation, isOfferClaimed } = useHeroOffer();
|
|
2001
1656
|
const { heading, subheading, metadata } = activeRecommendation.offer;
|
|
2002
1657
|
const primaryHeading = isOfferClaimed ? `You've got ${heading}` : heading;
|
|
2003
|
-
const secondaryHeading = isOfferClaimed && metadata.type === "PROMO_CODE" ? /* @__PURE__ */ jsxs(Fragment$
|
|
1658
|
+
const secondaryHeading = isOfferClaimed && metadata.type === "PROMO_CODE" ? /* @__PURE__ */ jsxs(Fragment$1, { children: ["Use code: ", /* @__PURE__ */ jsx$1("s-text", {
|
|
2004
1659
|
type: "strong",
|
|
2005
1660
|
children: metadata.code
|
|
2006
1661
|
})] }) : subheading || "On your next purchase";
|
|
@@ -2065,25 +1720,27 @@ function LeadGenActionNav() {
|
|
|
2065
1720
|
}
|
|
2066
1721
|
//#endregion
|
|
2067
1722
|
//#region src/components/RecommendationsWidget/index.tsx
|
|
2068
|
-
const
|
|
1723
|
+
const ESSENTIAL_LAYOUT_OPTIONS = new Map([
|
|
1724
|
+
["SHOPIFY_NATIVE_ESSENTIAL", {}],
|
|
1725
|
+
["SHOPIFY_NATIVE_ESSENTIAL_0.22", {}],
|
|
1726
|
+
["SHOPIFY_NATIVE_ESSENTIAL_0.23", { hero: {
|
|
1727
|
+
plainBody: true,
|
|
1728
|
+
inlineButtons: true
|
|
1729
|
+
} }],
|
|
1730
|
+
["SHOPIFY_NATIVE_ESSENTIAL_0.24", { scrollable: { splitTileHeading: true } }]
|
|
1731
|
+
]);
|
|
2069
1732
|
const Widget = () => {
|
|
2070
1733
|
const recommendationsData = useRecommendationsData();
|
|
2071
1734
|
const heroRecommendationGroup = recommendationsData.recommendationGroups.find((group) => group.slotContext === "HERO");
|
|
2072
1735
|
const scrollableRecommendationGroup = recommendationsData.recommendationGroups.find((group) => group.slotContext === "SCROLLABLE");
|
|
2073
1736
|
if (!heroRecommendationGroup && !scrollableRecommendationGroup) return null;
|
|
2074
1737
|
const layoutId = recommendationsData.layoutId;
|
|
2075
|
-
|
|
1738
|
+
const essentialLayoutOptions = ESSENTIAL_LAYOUT_OPTIONS.get(layoutId);
|
|
1739
|
+
if (essentialLayoutOptions) return /* @__PURE__ */ jsx$1(EssentialRecommendationsWidget, {
|
|
2076
1740
|
heroRecommendationGroup,
|
|
2077
|
-
scrollableRecommendationGroup
|
|
1741
|
+
scrollableRecommendationGroup,
|
|
1742
|
+
layoutOptions: essentialLayoutOptions
|
|
2078
1743
|
});
|
|
2079
|
-
if (layoutId === "SHOPIFY_NATIVE_ESSENTIAL_0.3") {
|
|
2080
|
-
if (!heroRecommendationGroup) return null;
|
|
2081
|
-
return /* @__PURE__ */ jsx$1(EssentialListRecommendationsWidget, { heroRecommendationGroup });
|
|
2082
|
-
}
|
|
2083
|
-
if (layoutId === "SHOPIFY_NATIVE_COVER") {
|
|
2084
|
-
if (!heroRecommendationGroup) return null;
|
|
2085
|
-
return /* @__PURE__ */ jsx$1(CoverRecommendationsWidget, { heroRecommendationGroup });
|
|
2086
|
-
}
|
|
2087
1744
|
return /* @__PURE__ */ jsx$1(LeadGen, {
|
|
2088
1745
|
heroRecommendationGroup,
|
|
2089
1746
|
scrollableRecommendationGroup
|
|
@@ -2494,7 +2151,7 @@ function PortableText({ value: input, components: componentOverrides, listNestin
|
|
|
2494
2151
|
let handleMissingComponent = missingComponentHandler || noop, blocks;
|
|
2495
2152
|
blocks = Array.isArray(input) ? input : input == null ? [] : [input];
|
|
2496
2153
|
let nested = nestLists(blocks, listNestingMode || "html"), components = useMemo$1(() => componentOverrides ? mergeComponents(defaultComponents, componentOverrides) : defaultComponents, [componentOverrides]), renderNode = useMemo$1(() => getNodeRenderer(components, handleMissingComponent), [components, handleMissingComponent]);
|
|
2497
|
-
return /* @__PURE__ */ jsx(Fragment
|
|
2154
|
+
return /* @__PURE__ */ jsx(Fragment, { children: nested.map((node, index) => renderNode({
|
|
2498
2155
|
node,
|
|
2499
2156
|
index,
|
|
2500
2157
|
isInline: !1,
|
|
@@ -3103,7 +2760,7 @@ function OptInYesNoRadios({ label, optInLabel, checked, onToggle }) {
|
|
|
3103
2760
|
* is worse than the layout this variant is measured against.
|
|
3104
2761
|
*/
|
|
3105
2762
|
function WithPartnerLogo({ source, children, format = "square", logoWidth }) {
|
|
3106
|
-
if (!source) return /* @__PURE__ */ jsx$1(Fragment$
|
|
2763
|
+
if (!source) return /* @__PURE__ */ jsx$1(Fragment$1, { children });
|
|
3107
2764
|
const aspectRatio = format === "wordmark" ? "5/2" : "1";
|
|
3108
2765
|
return /* @__PURE__ */ jsxs("s-grid", {
|
|
3109
2766
|
gridTemplateColumns: typeof logoWidth === "object" ? `@container (inline-size > ${logoWidth.containerAbove}) 1fr ${logoWidth.wide}, 1fr ${logoWidth.narrow}` : `minmax(0, 1fr) ${logoWidth ?? (format === "wordmark" ? "128px" : "48px")}`,
|
|
@@ -3222,7 +2879,7 @@ function OptInError({ message }) {
|
|
|
3222
2879
|
function TotalCashBack({ total, earned }) {
|
|
3223
2880
|
const tone = earned ? "success" : void 0;
|
|
3224
2881
|
const color = earned ? void 0 : "subdued";
|
|
3225
|
-
return /* @__PURE__ */ jsxs(Fragment$
|
|
2882
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx$1("s-divider", {}), /* @__PURE__ */ jsxs("s-grid", {
|
|
3226
2883
|
gridTemplateColumns: "1fr auto",
|
|
3227
2884
|
alignItems: "center",
|
|
3228
2885
|
children: [/* @__PURE__ */ jsxs("s-stack", {
|
|
@@ -3458,7 +3115,7 @@ function InlineRadioConfirmationWidget(props) {
|
|
|
3458
3115
|
return /* @__PURE__ */ jsxs("s-stack", {
|
|
3459
3116
|
gap: "small-200",
|
|
3460
3117
|
children: [
|
|
3461
|
-
checked ? /* @__PURE__ */ jsx$1(OptInConfirmation, { label: addedLabel }) : /* @__PURE__ */ jsxs(Fragment$
|
|
3118
|
+
checked ? /* @__PURE__ */ jsx$1(OptInConfirmation, { label: addedLabel }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx$1(RewardHeading, { label: rewardLabel }), /* @__PURE__ */ jsx$1(OptInYesNoChoice, {
|
|
3462
3119
|
label: rewardLabel,
|
|
3463
3120
|
optInLabel: optInChoiceLabel,
|
|
3464
3121
|
onOptIn: () => onToggle(true)
|
|
@@ -3588,7 +3245,7 @@ function InlineRadioConfirmationUndoWidget(props) {
|
|
|
3588
3245
|
return /* @__PURE__ */ jsxs("s-stack", {
|
|
3589
3246
|
gap: "small-200",
|
|
3590
3247
|
children: [
|
|
3591
|
-
checked ? /* @__PURE__ */ jsx$1(OptInConfirmation, { label: addedLabel }) : /* @__PURE__ */ jsxs(Fragment$
|
|
3248
|
+
checked ? /* @__PURE__ */ jsx$1(OptInConfirmation, { label: addedLabel }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx$1(RewardHeading, { label: rewardLabel }), /* @__PURE__ */ jsx$1(OptInYesNoChoice, {
|
|
3592
3249
|
label: rewardLabel,
|
|
3593
3250
|
optInLabel: optInChoiceLabel,
|
|
3594
3251
|
onOptIn: () => onToggle(true)
|
|
@@ -5193,4 +4850,4 @@ function OrderSubmitter({ trackingTicketId, idempotencyKey, insertionId }) {
|
|
|
5193
4850
|
//#endregion
|
|
5194
4851
|
export { DiscoRecommendations as a, PrepurchaseIncentive as i, PrepurchaseThankYou as n, Recommendations as o, DiscoPrepurchaseIncentive as r, DiscoPrepurchaseThankYou as t };
|
|
5195
4852
|
|
|
5196
|
-
//# sourceMappingURL=DiscoPrepurchaseThankYou-
|
|
4853
|
+
//# sourceMappingURL=DiscoPrepurchaseThankYou-Bp4WlM3S.js.map
|