@appstorys/react-web 1.0.1 → 1.1.1

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.mts CHANGED
@@ -2,21 +2,21 @@ import React from 'react';
2
2
 
3
3
  type CampaignType = 'BAN' | 'FLT' | 'PIP' | 'SUR' | 'CSAT' | 'WID' | 'MOD' | 'BTS' | 'SCRT' | 'STR' | 'TLTP' | 'TTP';
4
4
  interface CrossButtonConfig {
5
- color: {
6
- cross: string;
7
- fill: string;
8
- stroke: string;
5
+ color?: {
6
+ cross?: string;
7
+ fill?: string;
8
+ stroke?: string;
9
9
  };
10
- enabled: boolean;
11
- image: string;
12
- margin: {
13
- bottom: number;
14
- left: number;
15
- right: number;
16
- top: number;
10
+ enabled?: boolean;
11
+ image?: string;
12
+ margin?: {
13
+ bottom?: number;
14
+ left?: number;
15
+ right?: number;
16
+ top?: number;
17
17
  };
18
18
  selectedStyle?: string;
19
- size: number;
19
+ size?: number;
20
20
  }
21
21
  interface StorySlideCtaBorderRadius {
22
22
  topLeft?: number;
@@ -51,6 +51,8 @@ interface CampaignBanner extends BaseCampaign {
51
51
  lottie_data: string | null;
52
52
  width: null | number;
53
53
  height: null | number;
54
+ originalWidth?: null | number | string;
55
+ originalHeight?: null | number | string;
54
56
  link: null | string;
55
57
  styling: {
56
58
  bottomLeftRadius?: string;
@@ -251,6 +253,14 @@ interface TooltipStyling {
251
253
  right?: number;
252
254
  top?: number;
253
255
  };
256
+ /** When both width and height are set, the tooltip is treated as an
257
+ * image tooltip: the container is sized to this exact (viewport-clamped)
258
+ * box and the image is cropped to fill it edge-to-edge, matching RN's
259
+ * `imageDimensions` + `resizeMode="cover"` behavior. */
260
+ imageDimensions?: {
261
+ width?: number;
262
+ height?: number;
263
+ };
254
264
  };
255
265
  cta?: {
256
266
  container?: {
@@ -637,7 +647,115 @@ interface CampaignCsat extends BaseCampaign {
637
647
  campaign_type: 'CSAT';
638
648
  details: CsatCampaignDetails;
639
649
  }
640
- type Campaign = CampaignBanner | CampaignStory | CampaignWidget | CampaignTooltip | CampaignBottomSheet | CampaignCsat | CampaignSurvey | BaseCampaign;
650
+ interface ModalCtaRedirection {
651
+ key?: string;
652
+ pageName?: string;
653
+ type?: string;
654
+ url?: string;
655
+ value?: string;
656
+ }
657
+ interface ModalMediaType {
658
+ type?: 'image' | 'video' | string;
659
+ url?: string;
660
+ }
661
+ interface ModalContent {
662
+ chooseMediaType?: ModalMediaType;
663
+ primaryCtaRedirection?: ModalCtaRedirection;
664
+ primaryCtaText?: string;
665
+ secondaryCtaRedirection?: ModalCtaRedirection;
666
+ secondaryCtaText?: string;
667
+ subtitleText?: string;
668
+ titleText?: string;
669
+ }
670
+ interface ModalTextStyle {
671
+ color?: string;
672
+ fontDecoration?: string[];
673
+ fontFamily?: string;
674
+ fontSize?: number;
675
+ textAlign?: string;
676
+ }
677
+ interface ModalCtaStyle {
678
+ container?: {
679
+ alignment?: string;
680
+ backgroundColor?: string;
681
+ borderColor?: string;
682
+ borderWidth?: number;
683
+ ctaFullWidth?: boolean;
684
+ ctaWidth?: number;
685
+ height?: number;
686
+ };
687
+ cornerRadius?: {
688
+ bottomLeft?: number;
689
+ bottomRight?: number;
690
+ topLeft?: number;
691
+ topRight?: number;
692
+ };
693
+ margin?: {
694
+ bottom?: number;
695
+ left?: number;
696
+ right?: number;
697
+ top?: number;
698
+ };
699
+ text?: {
700
+ color?: string;
701
+ fontDecoration?: string[];
702
+ fontFamily?: string;
703
+ fontSize?: number;
704
+ };
705
+ }
706
+ interface ModalItemStyling {
707
+ appearance?: {
708
+ backdrop?: {
709
+ color?: string;
710
+ opacity?: number;
711
+ };
712
+ backgroundColor?: string;
713
+ cornerRadius?: {
714
+ bottomLeft?: number;
715
+ bottomRight?: number;
716
+ topLeft?: number;
717
+ topRight?: number;
718
+ };
719
+ dimension?: {
720
+ width?: number;
721
+ height?: number;
722
+ };
723
+ enableBackdrop?: boolean;
724
+ };
725
+ crossButton?: CrossButtonConfig;
726
+ primaryCta?: ModalCtaStyle;
727
+ secondaryCta?: ModalCtaStyle;
728
+ subTitle?: ModalTextStyle;
729
+ title?: ModalTextStyle;
730
+ }
731
+ interface ModalItem {
732
+ content?: ModalContent;
733
+ modal_type?: string;
734
+ modalType?: string;
735
+ screen?: number;
736
+ styling?: ModalItemStyling;
737
+ chooseMediaType?: ModalMediaType;
738
+ redirection?: ModalCtaRedirection;
739
+ image?: string;
740
+ video?: string;
741
+ }
742
+ interface ModalCampaignDetails {
743
+ id: string;
744
+ modal_type?: string;
745
+ modalType?: string;
746
+ modals?: ModalItem[];
747
+ chooseMediaType?: ModalMediaType;
748
+ redirection?: ModalCtaRedirection;
749
+ styling?: ModalItemStyling;
750
+ }
751
+ interface CampaignModal extends BaseCampaign {
752
+ campaign_type: 'MOD';
753
+ details: ModalCampaignDetails;
754
+ display_trigger?: boolean;
755
+ isTesting?: boolean;
756
+ priority?: number;
757
+ }
758
+ type Campaign = CampaignBanner | CampaignStory | CampaignWidget | CampaignTooltip | CampaignBottomSheet | CampaignCsat | CampaignSurvey | CampaignModal | BaseCampaign;
641
759
  interface InitializationOptions {
642
760
  appId: string;
643
761
  accountId: string;
@@ -683,6 +801,47 @@ declare const Csat: React.FC;
683
801
 
684
802
  declare const Survey: React.FC;
685
803
 
804
+ declare const Modal: React.FC;
805
+
806
+ interface TrackableProps {
807
+ /**
808
+ * AppStorys target identifier. Exposed to the DOM as `data-as-id` so the
809
+ * resolver can find it, measure it, and attach tooltips/campaigns to it —
810
+ * regardless of whether the wrapped component forwards custom props to
811
+ * its own root DOM node.
812
+ */
813
+ id: string;
814
+ children: React.ReactNode;
815
+ }
816
+ /**
817
+ * Wraps any child (native element or custom component) in a zero-layout-impact
818
+ * marker element carrying `data-as-id`. Use this when you can't or don't want
819
+ * to add `id`/`data-as-id` directly to a component's rendered DOM node, e.g.
820
+ * a third-party component or one that doesn't spread extra props onto its root:
821
+ *
822
+ * <Trackable id="checkout-button">
823
+ * <SomeThirdPartyButton>Checkout</SomeThirdPartyButton>
824
+ * </Trackable>
825
+ */
826
+ declare const Trackable: React.FC<TrackableProps>;
827
+
828
+ interface VariantDetails {
829
+ id?: string;
830
+ name?: string;
831
+ weight?: number;
832
+ isControl?: boolean;
833
+ isActive?: boolean;
834
+ modal_type?: string;
835
+ modals?: any[];
836
+ [key: string]: any;
837
+ }
838
+ type VariantsMap = Record<string, VariantDetails>;
839
+ declare const getVariantId: (campaignId: string) => string | undefined;
840
+ declare function hasVariants(campaign: Campaign | any): boolean;
841
+ declare function selectVariantByWeight(variants: VariantsMap, campaignId?: string): string | undefined;
842
+ declare function resolveCampaignVariant<T extends Campaign>(campaign: T): T;
843
+ declare function getCampaignVariantId(campaign: Campaign): string | undefined;
844
+
686
845
  declare class AppStorys {
687
846
  private state;
688
847
  private navigateToScreen?;
@@ -712,4 +871,4 @@ declare class AppStorys {
712
871
 
713
872
  declare const instance: AppStorys;
714
873
 
715
- export { instance as AppStorys, type AppStorysStore, type Attributes, Banner, type BaseCampaign, BottomSheet, type BottomSheetElement, type Campaign, type CampaignBanner, type CampaignBottomSheet, type CampaignCsat, type CampaignStory, type CampaignSurvey, type CampaignTooltip, type CampaignType, type CampaignWidget, type CrossButtonConfig, Csat, type CsatCampaignDetails, type CsatSpacing, type CsatTextStyle, Floater, type InitializationOptions, Pip, SdkState, Story, type StoryGroupStyling, type StorySlide, type StorySlideCta, type StorySlideCtaBorderRadius, type StorySlideCtaContainer, type StorySlideCtaText, type StorySlideStyling, Survey, type SurveyCampaignDetails, type SurveyOptionColors, type SurveyOptionStyle, type SurveySlide, type SurveySlideLogicRule, type SurveyTextStyle, type SurveyThankYouButtonConfig, Tooltip, type TooltipItem, type TooltipStyling, type TriggerEvent, type TriggerEventConfig, type TriggerEventObject, Widget, type WidgetImage, personalizeText };
874
+ export { instance as AppStorys, type AppStorysStore, type Attributes, Banner, type BaseCampaign, BottomSheet, type BottomSheetElement, type Campaign, type CampaignBanner, type CampaignBottomSheet, type CampaignCsat, type CampaignModal, type CampaignStory, type CampaignSurvey, type CampaignTooltip, type CampaignType, type CampaignWidget, type CrossButtonConfig, Csat, type CsatCampaignDetails, type CsatSpacing, type CsatTextStyle, Floater, type InitializationOptions, Modal, type ModalCampaignDetails, type ModalContent, type ModalCtaRedirection, type ModalCtaStyle, type ModalItem, type ModalItemStyling, type ModalMediaType, type ModalTextStyle, Pip, SdkState, Story, type StoryGroupStyling, type StorySlide, type StorySlideCta, type StorySlideCtaBorderRadius, type StorySlideCtaContainer, type StorySlideCtaText, type StorySlideStyling, Survey, type SurveyCampaignDetails, type SurveyOptionColors, type SurveyOptionStyle, type SurveySlide, type SurveySlideLogicRule, type SurveyTextStyle, type SurveyThankYouButtonConfig, Tooltip, type TooltipItem, type TooltipStyling, Trackable, type TrackableProps, type TriggerEvent, type TriggerEventConfig, type TriggerEventObject, type VariantDetails, type VariantsMap, Widget, type WidgetImage, getCampaignVariantId, getVariantId, hasVariants, personalizeText, resolveCampaignVariant, selectVariantByWeight };
package/dist/index.d.ts CHANGED
@@ -2,21 +2,21 @@ import React from 'react';
2
2
 
3
3
  type CampaignType = 'BAN' | 'FLT' | 'PIP' | 'SUR' | 'CSAT' | 'WID' | 'MOD' | 'BTS' | 'SCRT' | 'STR' | 'TLTP' | 'TTP';
4
4
  interface CrossButtonConfig {
5
- color: {
6
- cross: string;
7
- fill: string;
8
- stroke: string;
5
+ color?: {
6
+ cross?: string;
7
+ fill?: string;
8
+ stroke?: string;
9
9
  };
10
- enabled: boolean;
11
- image: string;
12
- margin: {
13
- bottom: number;
14
- left: number;
15
- right: number;
16
- top: number;
10
+ enabled?: boolean;
11
+ image?: string;
12
+ margin?: {
13
+ bottom?: number;
14
+ left?: number;
15
+ right?: number;
16
+ top?: number;
17
17
  };
18
18
  selectedStyle?: string;
19
- size: number;
19
+ size?: number;
20
20
  }
21
21
  interface StorySlideCtaBorderRadius {
22
22
  topLeft?: number;
@@ -51,6 +51,8 @@ interface CampaignBanner extends BaseCampaign {
51
51
  lottie_data: string | null;
52
52
  width: null | number;
53
53
  height: null | number;
54
+ originalWidth?: null | number | string;
55
+ originalHeight?: null | number | string;
54
56
  link: null | string;
55
57
  styling: {
56
58
  bottomLeftRadius?: string;
@@ -251,6 +253,14 @@ interface TooltipStyling {
251
253
  right?: number;
252
254
  top?: number;
253
255
  };
256
+ /** When both width and height are set, the tooltip is treated as an
257
+ * image tooltip: the container is sized to this exact (viewport-clamped)
258
+ * box and the image is cropped to fill it edge-to-edge, matching RN's
259
+ * `imageDimensions` + `resizeMode="cover"` behavior. */
260
+ imageDimensions?: {
261
+ width?: number;
262
+ height?: number;
263
+ };
254
264
  };
255
265
  cta?: {
256
266
  container?: {
@@ -637,7 +647,115 @@ interface CampaignCsat extends BaseCampaign {
637
647
  campaign_type: 'CSAT';
638
648
  details: CsatCampaignDetails;
639
649
  }
640
- type Campaign = CampaignBanner | CampaignStory | CampaignWidget | CampaignTooltip | CampaignBottomSheet | CampaignCsat | CampaignSurvey | BaseCampaign;
650
+ interface ModalCtaRedirection {
651
+ key?: string;
652
+ pageName?: string;
653
+ type?: string;
654
+ url?: string;
655
+ value?: string;
656
+ }
657
+ interface ModalMediaType {
658
+ type?: 'image' | 'video' | string;
659
+ url?: string;
660
+ }
661
+ interface ModalContent {
662
+ chooseMediaType?: ModalMediaType;
663
+ primaryCtaRedirection?: ModalCtaRedirection;
664
+ primaryCtaText?: string;
665
+ secondaryCtaRedirection?: ModalCtaRedirection;
666
+ secondaryCtaText?: string;
667
+ subtitleText?: string;
668
+ titleText?: string;
669
+ }
670
+ interface ModalTextStyle {
671
+ color?: string;
672
+ fontDecoration?: string[];
673
+ fontFamily?: string;
674
+ fontSize?: number;
675
+ textAlign?: string;
676
+ }
677
+ interface ModalCtaStyle {
678
+ container?: {
679
+ alignment?: string;
680
+ backgroundColor?: string;
681
+ borderColor?: string;
682
+ borderWidth?: number;
683
+ ctaFullWidth?: boolean;
684
+ ctaWidth?: number;
685
+ height?: number;
686
+ };
687
+ cornerRadius?: {
688
+ bottomLeft?: number;
689
+ bottomRight?: number;
690
+ topLeft?: number;
691
+ topRight?: number;
692
+ };
693
+ margin?: {
694
+ bottom?: number;
695
+ left?: number;
696
+ right?: number;
697
+ top?: number;
698
+ };
699
+ text?: {
700
+ color?: string;
701
+ fontDecoration?: string[];
702
+ fontFamily?: string;
703
+ fontSize?: number;
704
+ };
705
+ }
706
+ interface ModalItemStyling {
707
+ appearance?: {
708
+ backdrop?: {
709
+ color?: string;
710
+ opacity?: number;
711
+ };
712
+ backgroundColor?: string;
713
+ cornerRadius?: {
714
+ bottomLeft?: number;
715
+ bottomRight?: number;
716
+ topLeft?: number;
717
+ topRight?: number;
718
+ };
719
+ dimension?: {
720
+ width?: number;
721
+ height?: number;
722
+ };
723
+ enableBackdrop?: boolean;
724
+ };
725
+ crossButton?: CrossButtonConfig;
726
+ primaryCta?: ModalCtaStyle;
727
+ secondaryCta?: ModalCtaStyle;
728
+ subTitle?: ModalTextStyle;
729
+ title?: ModalTextStyle;
730
+ }
731
+ interface ModalItem {
732
+ content?: ModalContent;
733
+ modal_type?: string;
734
+ modalType?: string;
735
+ screen?: number;
736
+ styling?: ModalItemStyling;
737
+ chooseMediaType?: ModalMediaType;
738
+ redirection?: ModalCtaRedirection;
739
+ image?: string;
740
+ video?: string;
741
+ }
742
+ interface ModalCampaignDetails {
743
+ id: string;
744
+ modal_type?: string;
745
+ modalType?: string;
746
+ modals?: ModalItem[];
747
+ chooseMediaType?: ModalMediaType;
748
+ redirection?: ModalCtaRedirection;
749
+ styling?: ModalItemStyling;
750
+ }
751
+ interface CampaignModal extends BaseCampaign {
752
+ campaign_type: 'MOD';
753
+ details: ModalCampaignDetails;
754
+ display_trigger?: boolean;
755
+ isTesting?: boolean;
756
+ priority?: number;
757
+ }
758
+ type Campaign = CampaignBanner | CampaignStory | CampaignWidget | CampaignTooltip | CampaignBottomSheet | CampaignCsat | CampaignSurvey | CampaignModal | BaseCampaign;
641
759
  interface InitializationOptions {
642
760
  appId: string;
643
761
  accountId: string;
@@ -683,6 +801,47 @@ declare const Csat: React.FC;
683
801
 
684
802
  declare const Survey: React.FC;
685
803
 
804
+ declare const Modal: React.FC;
805
+
806
+ interface TrackableProps {
807
+ /**
808
+ * AppStorys target identifier. Exposed to the DOM as `data-as-id` so the
809
+ * resolver can find it, measure it, and attach tooltips/campaigns to it —
810
+ * regardless of whether the wrapped component forwards custom props to
811
+ * its own root DOM node.
812
+ */
813
+ id: string;
814
+ children: React.ReactNode;
815
+ }
816
+ /**
817
+ * Wraps any child (native element or custom component) in a zero-layout-impact
818
+ * marker element carrying `data-as-id`. Use this when you can't or don't want
819
+ * to add `id`/`data-as-id` directly to a component's rendered DOM node, e.g.
820
+ * a third-party component or one that doesn't spread extra props onto its root:
821
+ *
822
+ * <Trackable id="checkout-button">
823
+ * <SomeThirdPartyButton>Checkout</SomeThirdPartyButton>
824
+ * </Trackable>
825
+ */
826
+ declare const Trackable: React.FC<TrackableProps>;
827
+
828
+ interface VariantDetails {
829
+ id?: string;
830
+ name?: string;
831
+ weight?: number;
832
+ isControl?: boolean;
833
+ isActive?: boolean;
834
+ modal_type?: string;
835
+ modals?: any[];
836
+ [key: string]: any;
837
+ }
838
+ type VariantsMap = Record<string, VariantDetails>;
839
+ declare const getVariantId: (campaignId: string) => string | undefined;
840
+ declare function hasVariants(campaign: Campaign | any): boolean;
841
+ declare function selectVariantByWeight(variants: VariantsMap, campaignId?: string): string | undefined;
842
+ declare function resolveCampaignVariant<T extends Campaign>(campaign: T): T;
843
+ declare function getCampaignVariantId(campaign: Campaign): string | undefined;
844
+
686
845
  declare class AppStorys {
687
846
  private state;
688
847
  private navigateToScreen?;
@@ -712,4 +871,4 @@ declare class AppStorys {
712
871
 
713
872
  declare const instance: AppStorys;
714
873
 
715
- export { instance as AppStorys, type AppStorysStore, type Attributes, Banner, type BaseCampaign, BottomSheet, type BottomSheetElement, type Campaign, type CampaignBanner, type CampaignBottomSheet, type CampaignCsat, type CampaignStory, type CampaignSurvey, type CampaignTooltip, type CampaignType, type CampaignWidget, type CrossButtonConfig, Csat, type CsatCampaignDetails, type CsatSpacing, type CsatTextStyle, Floater, type InitializationOptions, Pip, SdkState, Story, type StoryGroupStyling, type StorySlide, type StorySlideCta, type StorySlideCtaBorderRadius, type StorySlideCtaContainer, type StorySlideCtaText, type StorySlideStyling, Survey, type SurveyCampaignDetails, type SurveyOptionColors, type SurveyOptionStyle, type SurveySlide, type SurveySlideLogicRule, type SurveyTextStyle, type SurveyThankYouButtonConfig, Tooltip, type TooltipItem, type TooltipStyling, type TriggerEvent, type TriggerEventConfig, type TriggerEventObject, Widget, type WidgetImage, personalizeText };
874
+ export { instance as AppStorys, type AppStorysStore, type Attributes, Banner, type BaseCampaign, BottomSheet, type BottomSheetElement, type Campaign, type CampaignBanner, type CampaignBottomSheet, type CampaignCsat, type CampaignModal, type CampaignStory, type CampaignSurvey, type CampaignTooltip, type CampaignType, type CampaignWidget, type CrossButtonConfig, Csat, type CsatCampaignDetails, type CsatSpacing, type CsatTextStyle, Floater, type InitializationOptions, Modal, type ModalCampaignDetails, type ModalContent, type ModalCtaRedirection, type ModalCtaStyle, type ModalItem, type ModalItemStyling, type ModalMediaType, type ModalTextStyle, Pip, SdkState, Story, type StoryGroupStyling, type StorySlide, type StorySlideCta, type StorySlideCtaBorderRadius, type StorySlideCtaContainer, type StorySlideCtaText, type StorySlideStyling, Survey, type SurveyCampaignDetails, type SurveyOptionColors, type SurveyOptionStyle, type SurveySlide, type SurveySlideLogicRule, type SurveyTextStyle, type SurveyThankYouButtonConfig, Tooltip, type TooltipItem, type TooltipStyling, Trackable, type TrackableProps, type TriggerEvent, type TriggerEventConfig, type TriggerEventObject, type VariantDetails, type VariantsMap, Widget, type WidgetImage, getCampaignVariantId, getVariantId, hasVariants, personalizeText, resolveCampaignVariant, selectVariantByWeight };