@appstorys/react-web 1.1.0 → 1.1.2

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;
@@ -90,8 +92,13 @@ interface AppStorysStore {
90
92
  variantMappings: Record<string, string>;
91
93
  personalizationData: Record<string, string>;
92
94
  screenCaptureEnabled?: boolean;
95
+ /** @deprecated use `usersUrl` */
93
96
  baseUrl?: string;
97
+ usersUrl?: string;
94
98
  trackingUrl?: string;
99
+ campaignsUrl?: string;
100
+ mediaUrl?: string;
101
+ backendUrl?: string;
95
102
  }
96
103
  interface StorySlideCtaContainer {
97
104
  alignment?: string;
@@ -154,6 +161,7 @@ interface StoryGroupStyling {
154
161
  size?: number;
155
162
  };
156
163
  ringWidth?: number;
164
+ ringAndImageSpace?: number;
157
165
  share?: {
158
166
  color?: {
159
167
  cross?: string;
@@ -251,6 +259,15 @@ interface TooltipStyling {
251
259
  right?: number;
252
260
  top?: number;
253
261
  };
262
+ width?: number;
263
+ /** When both width and height are set, the tooltip is treated as an
264
+ * image tooltip: the container is sized to this exact (viewport-clamped)
265
+ * box and the image is cropped to fill it edge-to-edge, matching RN's
266
+ * `imageDimensions` + `resizeMode="cover"` behavior. */
267
+ imageDimensions?: {
268
+ width?: number;
269
+ height?: number;
270
+ };
254
271
  };
255
272
  cta?: {
256
273
  container?: {
@@ -448,6 +465,12 @@ interface SurveyCampaignDetails {
448
465
  imageStyle?: {
449
466
  height?: number;
450
467
  width?: number;
468
+ margin?: {
469
+ bottom?: number;
470
+ left?: number;
471
+ right?: number;
472
+ top?: number;
473
+ };
451
474
  };
452
475
  subtitle?: {
453
476
  textStyle?: SurveyTextStyle;
@@ -559,7 +582,35 @@ interface CsatCampaignDetails {
559
582
  };
560
583
  };
561
584
  rating?: {
562
- emoji?: string[] | Record<string, string> | string | null;
585
+ /** Horizontal alignment of the rating row: 'left' | 'center' | 'right' */
586
+ alignment?: string;
587
+ /** Corner radius applied to all rating item containers */
588
+ cornerRadius?: {
589
+ topLeft?: number;
590
+ topRight?: number;
591
+ bottomLeft?: number;
592
+ bottomRight?: number;
593
+ };
594
+ /** Arbitrary display-text label (reserved, not yet rendered) */
595
+ displayText?: string;
596
+ /** Emoji options — backend sends object form { selected, unselected, values } */
597
+ emoji?: string[] | string | null | {
598
+ selected?: {
599
+ stylingContainer?: {
600
+ border?: string;
601
+ borderWidth?: number;
602
+ fill?: string;
603
+ };
604
+ };
605
+ unselected?: {
606
+ stylingContainer?: {
607
+ border?: string;
608
+ borderWidth?: number;
609
+ fill?: string;
610
+ };
611
+ };
612
+ values?: string[];
613
+ };
563
614
  highRatingSubtitle?: string;
564
615
  highRatingTitle?: string;
565
616
  lowRatingSubtitle?: string;
@@ -567,8 +618,43 @@ interface CsatCampaignDetails {
567
618
  number?: number | {
568
619
  min?: number;
569
620
  max?: number;
621
+ high?: {
622
+ stylingContainer?: {
623
+ fill?: string;
624
+ background?: string;
625
+ border?: string;
626
+ borderWidth?: number;
627
+ };
628
+ };
629
+ low?: {
630
+ stylingContainer?: {
631
+ fill?: string;
632
+ background?: string;
633
+ border?: string;
634
+ borderWidth?: number;
635
+ };
636
+ };
637
+ unselected?: {
638
+ stylingContainer?: {
639
+ fill?: string;
640
+ background?: string;
641
+ border?: string;
642
+ borderWidth?: number;
643
+ };
644
+ stylingNumber?: {
645
+ text?: string;
646
+ textSize?: number;
647
+ };
648
+ };
649
+ /** Text styling applied to the number label when the button is selected */
650
+ stylingNumber?: {
651
+ text?: string;
652
+ textSize?: number;
653
+ };
570
654
  } | null;
571
655
  ratingType?: string;
656
+ /** Gap (px) between rating items for star and emoji types */
657
+ spacing?: number;
572
658
  star?: {
573
659
  high?: {
574
660
  stylingContainer?: {
@@ -615,6 +701,8 @@ interface CsatCampaignDetails {
615
701
  };
616
702
  imageStyle?: {
617
703
  height?: number;
704
+ /** Margin around the thank-you image */
705
+ margin?: CsatSpacing;
618
706
  width?: number;
619
707
  };
620
708
  subtitle?: {
@@ -637,13 +725,131 @@ interface CampaignCsat extends BaseCampaign {
637
725
  campaign_type: 'CSAT';
638
726
  details: CsatCampaignDetails;
639
727
  }
640
- type Campaign = CampaignBanner | CampaignStory | CampaignWidget | CampaignTooltip | CampaignBottomSheet | CampaignCsat | CampaignSurvey | BaseCampaign;
728
+ interface ModalCtaRedirection {
729
+ key?: string;
730
+ pageName?: string;
731
+ type?: string;
732
+ url?: string;
733
+ value?: string;
734
+ }
735
+ interface ModalMediaType {
736
+ type?: 'image' | 'video' | string;
737
+ url?: string;
738
+ }
739
+ interface ModalContent {
740
+ chooseMediaType?: ModalMediaType;
741
+ primaryCtaRedirection?: ModalCtaRedirection;
742
+ primaryCtaText?: string;
743
+ secondaryCtaRedirection?: ModalCtaRedirection;
744
+ secondaryCtaText?: string;
745
+ subtitleText?: string;
746
+ titleText?: string;
747
+ }
748
+ interface ModalTextStyle {
749
+ color?: string;
750
+ fontDecoration?: string[];
751
+ fontFamily?: string;
752
+ fontSize?: number;
753
+ textAlign?: string;
754
+ }
755
+ interface ModalCtaStyle {
756
+ container?: {
757
+ alignment?: string;
758
+ backgroundColor?: string;
759
+ borderColor?: string;
760
+ borderWidth?: number;
761
+ ctaFullWidth?: boolean;
762
+ ctaWidth?: number;
763
+ height?: number;
764
+ };
765
+ cornerRadius?: {
766
+ bottomLeft?: number;
767
+ bottomRight?: number;
768
+ topLeft?: number;
769
+ topRight?: number;
770
+ };
771
+ margin?: {
772
+ bottom?: number;
773
+ left?: number;
774
+ right?: number;
775
+ top?: number;
776
+ };
777
+ text?: {
778
+ color?: string;
779
+ fontDecoration?: string[];
780
+ fontFamily?: string;
781
+ fontSize?: number;
782
+ };
783
+ }
784
+ interface ModalItemStyling {
785
+ appearance?: {
786
+ backdrop?: {
787
+ color?: string;
788
+ opacity?: number;
789
+ };
790
+ backgroundColor?: string;
791
+ cornerRadius?: {
792
+ bottomLeft?: number;
793
+ bottomRight?: number;
794
+ topLeft?: number;
795
+ topRight?: number;
796
+ };
797
+ dimension?: {
798
+ width?: number;
799
+ height?: number;
800
+ };
801
+ enableBackdrop?: boolean;
802
+ };
803
+ crossButton?: CrossButtonConfig;
804
+ primaryCta?: ModalCtaStyle;
805
+ secondaryCta?: ModalCtaStyle;
806
+ subTitle?: ModalTextStyle;
807
+ title?: ModalTextStyle;
808
+ }
809
+ interface ModalItem {
810
+ content?: ModalContent;
811
+ modal_type?: string;
812
+ modalType?: string;
813
+ screen?: number;
814
+ styling?: ModalItemStyling;
815
+ chooseMediaType?: ModalMediaType;
816
+ redirection?: ModalCtaRedirection;
817
+ image?: string;
818
+ video?: string;
819
+ }
820
+ interface ModalCampaignDetails {
821
+ id: string;
822
+ modal_type?: string;
823
+ modalType?: string;
824
+ modals?: ModalItem[];
825
+ chooseMediaType?: ModalMediaType;
826
+ redirection?: ModalCtaRedirection;
827
+ styling?: ModalItemStyling;
828
+ }
829
+ interface CampaignModal extends BaseCampaign {
830
+ campaign_type: 'MOD';
831
+ details: ModalCampaignDetails;
832
+ display_trigger?: boolean;
833
+ isTesting?: boolean;
834
+ priority?: number;
835
+ }
836
+ type Campaign = CampaignBanner | CampaignStory | CampaignWidget | CampaignTooltip | CampaignBottomSheet | CampaignCsat | CampaignSurvey | CampaignModal | BaseCampaign;
641
837
  interface InitializationOptions {
642
838
  appId: string;
643
839
  accountId: string;
644
840
  userId?: string;
841
+ /** @deprecated use `usersUrl` */
645
842
  baseUrl?: string;
843
+ /** Override the users host (default https://users.appstorys.co). */
844
+ usersUrl?: string;
845
+ /** Override the tracking host (default https://tracking.appstorys.co). */
646
846
  trackingUrl?: string;
847
+ /** Override the campaigns CDN host. */
848
+ campaignsUrl?: string;
849
+ /** Override the media bucket host. */
850
+ mediaUrl?: string;
851
+ /** Override the backend/appinfo host (default https://backend.appstorys.co). */
852
+ backendUrl?: string;
647
853
  navigateToScreen?: (screen: string) => void;
648
854
  }
649
855
 
@@ -683,6 +889,47 @@ declare const Csat: React.FC;
683
889
 
684
890
  declare const Survey: React.FC;
685
891
 
892
+ declare const Modal: React.FC;
893
+
894
+ interface TrackableProps {
895
+ /**
896
+ * AppStorys target identifier. Exposed to the DOM as `data-as-id` so the
897
+ * resolver can find it, measure it, and attach tooltips/campaigns to it —
898
+ * regardless of whether the wrapped component forwards custom props to
899
+ * its own root DOM node.
900
+ */
901
+ id: string;
902
+ children: React.ReactNode;
903
+ }
904
+ /**
905
+ * Wraps any child (native element or custom component) in a zero-layout-impact
906
+ * marker element carrying `data-as-id`. Use this when you can't or don't want
907
+ * to add `id`/`data-as-id` directly to a component's rendered DOM node, e.g.
908
+ * a third-party component or one that doesn't spread extra props onto its root:
909
+ *
910
+ * <Trackable id="checkout-button">
911
+ * <SomeThirdPartyButton>Checkout</SomeThirdPartyButton>
912
+ * </Trackable>
913
+ */
914
+ declare const Trackable: React.FC<TrackableProps>;
915
+
916
+ interface VariantDetails {
917
+ id?: string;
918
+ name?: string;
919
+ weight?: number;
920
+ isControl?: boolean;
921
+ isActive?: boolean;
922
+ modal_type?: string;
923
+ modals?: any[];
924
+ [key: string]: any;
925
+ }
926
+ type VariantsMap = Record<string, VariantDetails>;
927
+ declare const getVariantId: (campaignId: string) => string | undefined;
928
+ declare function hasVariants(campaign: Campaign | any): boolean;
929
+ declare function selectVariantByWeight(variants: VariantsMap, campaignId?: string): string | undefined;
930
+ declare function resolveCampaignVariant<T extends Campaign>(campaign: T): T;
931
+ declare function getCampaignVariantId(campaign: Campaign): string | undefined;
932
+
686
933
  declare class AppStorys {
687
934
  private state;
688
935
  private navigateToScreen?;
@@ -712,4 +959,4 @@ declare class AppStorys {
712
959
 
713
960
  declare const instance: AppStorys;
714
961
 
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 };
962
+ 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 };