@appstorys/react-web 1.1.2 → 1.1.3

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
@@ -1,4 +1,20 @@
1
- import React from 'react';
1
+ import * as React from 'react';
2
+ import React__default from 'react';
3
+
4
+ interface WidgetProps {
5
+ position?: string;
6
+ leftPadding?: number;
7
+ rightPadding?: number;
8
+ }
9
+ /**
10
+ * Web widget component mirroring RN Widgets.tsx implementation
11
+ * - Accepts optional position, leftPadding, rightPadding props
12
+ * - Fetches single campaign via useCampaigns hook
13
+ * - Renders carousel with auto-advance (full) or manual scroll (half)
14
+ * - Supports static images and Lottie animations
15
+ * - Portals into host element if position target found
16
+ */
17
+ declare const Widget: React__default.FC<WidgetProps>;
2
18
 
3
19
  type CampaignType = 'BAN' | 'FLT' | 'PIP' | 'SUR' | 'CSAT' | 'WID' | 'MOD' | 'BTS' | 'SCRT' | 'STR' | 'TLTP' | 'TTP';
4
20
  interface CrossButtonConfig {
@@ -41,7 +57,11 @@ interface BaseCampaign {
41
57
  trigger_event?: TriggerEvent;
42
58
  position?: string;
43
59
  screen?: string;
60
+ priority?: number;
44
61
  details: any;
62
+ isTesting?: boolean;
63
+ testUsers?: string[];
64
+ display_trigger?: boolean;
45
65
  }
46
66
  interface CampaignBanner extends BaseCampaign {
47
67
  campaign_type: 'BAN';
@@ -853,11 +873,11 @@ interface InitializationOptions {
853
873
  navigateToScreen?: (screen: string) => void;
854
874
  }
855
875
 
856
- declare const Banner: React.FC;
876
+ declare const Banner: React__default.FC;
857
877
 
858
- declare const Pip: React.FC;
878
+ declare const Pip: React__default.FC;
859
879
 
860
- declare const Floater: React.FC;
880
+ declare const Floater: React__default.FC;
861
881
 
862
882
  declare function personalizeText(text: string): string;
863
883
 
@@ -867,29 +887,17 @@ declare global {
867
887
  }
868
888
  }
869
889
 
870
- declare const Story: React.FC;
890
+ declare const Story: React__default.FC;
871
891
 
872
- interface WidgetProps {
873
- position?: string;
874
- }
875
- /**
876
- * Simple web widget component mirroring RN Widgets.tsx implementation
877
- * - Accepts optional position prop
878
- * - Fetches single campaign via useCampaigns hook
879
- * - Renders carousel with auto-advance (full) or manual scroll (half)
880
- * - Portals into host element if position target found
881
- */
882
- declare const Widget: React.FC<WidgetProps>;
892
+ declare const Tooltip: React__default.FC;
883
893
 
884
- declare const Tooltip: React.FC;
894
+ declare const BottomSheet: React__default.FC;
885
895
 
886
- declare const BottomSheet: React.FC;
896
+ declare const Csat: React__default.FC;
887
897
 
888
- declare const Csat: React.FC;
898
+ declare const Survey: React__default.FC;
889
899
 
890
- declare const Survey: React.FC;
891
-
892
- declare const Modal: React.FC;
900
+ declare const Modal: React__default.FC;
893
901
 
894
902
  interface TrackableProps {
895
903
  /**
@@ -899,7 +907,7 @@ interface TrackableProps {
899
907
  * its own root DOM node.
900
908
  */
901
909
  id: string;
902
- children: React.ReactNode;
910
+ children: React__default.ReactNode;
903
911
  }
904
912
  /**
905
913
  * Wraps any child (native element or custom component) in a zero-layout-impact
@@ -911,7 +919,7 @@ interface TrackableProps {
911
919
  * <SomeThirdPartyButton>Checkout</SomeThirdPartyButton>
912
920
  * </Trackable>
913
921
  */
914
- declare const Trackable: React.FC<TrackableProps>;
922
+ declare const Trackable: React__default.FC<TrackableProps>;
915
923
 
916
924
  interface VariantDetails {
917
925
  id?: string;
@@ -930,6 +938,33 @@ declare function selectVariantByWeight(variants: VariantsMap, campaignId?: strin
930
938
  declare function resolveCampaignVariant<T extends Campaign>(campaign: T): T;
931
939
  declare function getCampaignVariantId(campaign: Campaign): string | undefined;
932
940
 
941
+ declare const DEFAULT_OVERLAY_PRIORITIES: Record<string, number>;
942
+ declare const BASE_OVERLAY_Z_INDEX = 10000;
943
+ interface ResolvedPriority {
944
+ priority: number;
945
+ hasExplicitPriority: boolean;
946
+ }
947
+ /**
948
+ * Parses the campaign priority. Backend sends 1-indexed priority (starting from 1).
949
+ * If no valid positive priority is specified in JSON, falls back to the default overlay rank.
950
+ */
951
+ declare function parseCampaignPriority(campaign: any): ResolvedPriority;
952
+ /**
953
+ * Compares two campaigns for priority order.
954
+ * - Explicit priorities take precedence on ties.
955
+ * - Lower priority number (1, 2, 3...) indicates higher priority ranking.
956
+ */
957
+ declare function compareCampaignPriority(a: any, b: any): number;
958
+ /**
959
+ * Stably sorts an array of campaigns by priority (highest priority first).
960
+ */
961
+ declare function sortCampaignsByPriority<T extends Campaign>(campaigns: T[]): T[];
962
+ /**
963
+ * Computes the dynamic z-index for an overlay campaign.
964
+ * Stacking order matches priority ranks (Rank 1 at back, Rank 10 at top front).
965
+ */
966
+ declare function getCampaignZIndex(campaign?: any, fallbackType?: CampaignType | string, baseZIndex?: number): number;
967
+
933
968
  declare class AppStorys {
934
969
  private state;
935
970
  private navigateToScreen?;
@@ -955,8 +990,10 @@ declare class AppStorys {
955
990
  set visibility(isVisible: boolean);
956
991
  private ensureInitialized;
957
992
  personalizeText(text: string): string;
993
+ Widget: React.FC<WidgetProps>;
994
+ Widgets: React.FC<WidgetProps>;
958
995
  }
959
996
 
960
997
  declare const instance: AppStorys;
961
998
 
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 };
999
+ export { instance as AppStorys, type AppStorysStore, type Attributes, BASE_OVERLAY_Z_INDEX, 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, DEFAULT_OVERLAY_PRIORITIES, Floater, type InitializationOptions, Modal, type ModalCampaignDetails, type ModalContent, type ModalCtaRedirection, type ModalCtaStyle, type ModalItem, type ModalItemStyling, type ModalMediaType, type ModalTextStyle, Pip, type ResolvedPriority, 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, type WidgetProps, Widget as Widgets, compareCampaignPriority, getCampaignVariantId, getCampaignZIndex, getVariantId, hasVariants, parseCampaignPriority, personalizeText, resolveCampaignVariant, selectVariantByWeight, sortCampaignsByPriority };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,20 @@
1
- import React from 'react';
1
+ import * as React from 'react';
2
+ import React__default from 'react';
3
+
4
+ interface WidgetProps {
5
+ position?: string;
6
+ leftPadding?: number;
7
+ rightPadding?: number;
8
+ }
9
+ /**
10
+ * Web widget component mirroring RN Widgets.tsx implementation
11
+ * - Accepts optional position, leftPadding, rightPadding props
12
+ * - Fetches single campaign via useCampaigns hook
13
+ * - Renders carousel with auto-advance (full) or manual scroll (half)
14
+ * - Supports static images and Lottie animations
15
+ * - Portals into host element if position target found
16
+ */
17
+ declare const Widget: React__default.FC<WidgetProps>;
2
18
 
3
19
  type CampaignType = 'BAN' | 'FLT' | 'PIP' | 'SUR' | 'CSAT' | 'WID' | 'MOD' | 'BTS' | 'SCRT' | 'STR' | 'TLTP' | 'TTP';
4
20
  interface CrossButtonConfig {
@@ -41,7 +57,11 @@ interface BaseCampaign {
41
57
  trigger_event?: TriggerEvent;
42
58
  position?: string;
43
59
  screen?: string;
60
+ priority?: number;
44
61
  details: any;
62
+ isTesting?: boolean;
63
+ testUsers?: string[];
64
+ display_trigger?: boolean;
45
65
  }
46
66
  interface CampaignBanner extends BaseCampaign {
47
67
  campaign_type: 'BAN';
@@ -853,11 +873,11 @@ interface InitializationOptions {
853
873
  navigateToScreen?: (screen: string) => void;
854
874
  }
855
875
 
856
- declare const Banner: React.FC;
876
+ declare const Banner: React__default.FC;
857
877
 
858
- declare const Pip: React.FC;
878
+ declare const Pip: React__default.FC;
859
879
 
860
- declare const Floater: React.FC;
880
+ declare const Floater: React__default.FC;
861
881
 
862
882
  declare function personalizeText(text: string): string;
863
883
 
@@ -867,29 +887,17 @@ declare global {
867
887
  }
868
888
  }
869
889
 
870
- declare const Story: React.FC;
890
+ declare const Story: React__default.FC;
871
891
 
872
- interface WidgetProps {
873
- position?: string;
874
- }
875
- /**
876
- * Simple web widget component mirroring RN Widgets.tsx implementation
877
- * - Accepts optional position prop
878
- * - Fetches single campaign via useCampaigns hook
879
- * - Renders carousel with auto-advance (full) or manual scroll (half)
880
- * - Portals into host element if position target found
881
- */
882
- declare const Widget: React.FC<WidgetProps>;
892
+ declare const Tooltip: React__default.FC;
883
893
 
884
- declare const Tooltip: React.FC;
894
+ declare const BottomSheet: React__default.FC;
885
895
 
886
- declare const BottomSheet: React.FC;
896
+ declare const Csat: React__default.FC;
887
897
 
888
- declare const Csat: React.FC;
898
+ declare const Survey: React__default.FC;
889
899
 
890
- declare const Survey: React.FC;
891
-
892
- declare const Modal: React.FC;
900
+ declare const Modal: React__default.FC;
893
901
 
894
902
  interface TrackableProps {
895
903
  /**
@@ -899,7 +907,7 @@ interface TrackableProps {
899
907
  * its own root DOM node.
900
908
  */
901
909
  id: string;
902
- children: React.ReactNode;
910
+ children: React__default.ReactNode;
903
911
  }
904
912
  /**
905
913
  * Wraps any child (native element or custom component) in a zero-layout-impact
@@ -911,7 +919,7 @@ interface TrackableProps {
911
919
  * <SomeThirdPartyButton>Checkout</SomeThirdPartyButton>
912
920
  * </Trackable>
913
921
  */
914
- declare const Trackable: React.FC<TrackableProps>;
922
+ declare const Trackable: React__default.FC<TrackableProps>;
915
923
 
916
924
  interface VariantDetails {
917
925
  id?: string;
@@ -930,6 +938,33 @@ declare function selectVariantByWeight(variants: VariantsMap, campaignId?: strin
930
938
  declare function resolveCampaignVariant<T extends Campaign>(campaign: T): T;
931
939
  declare function getCampaignVariantId(campaign: Campaign): string | undefined;
932
940
 
941
+ declare const DEFAULT_OVERLAY_PRIORITIES: Record<string, number>;
942
+ declare const BASE_OVERLAY_Z_INDEX = 10000;
943
+ interface ResolvedPriority {
944
+ priority: number;
945
+ hasExplicitPriority: boolean;
946
+ }
947
+ /**
948
+ * Parses the campaign priority. Backend sends 1-indexed priority (starting from 1).
949
+ * If no valid positive priority is specified in JSON, falls back to the default overlay rank.
950
+ */
951
+ declare function parseCampaignPriority(campaign: any): ResolvedPriority;
952
+ /**
953
+ * Compares two campaigns for priority order.
954
+ * - Explicit priorities take precedence on ties.
955
+ * - Lower priority number (1, 2, 3...) indicates higher priority ranking.
956
+ */
957
+ declare function compareCampaignPriority(a: any, b: any): number;
958
+ /**
959
+ * Stably sorts an array of campaigns by priority (highest priority first).
960
+ */
961
+ declare function sortCampaignsByPriority<T extends Campaign>(campaigns: T[]): T[];
962
+ /**
963
+ * Computes the dynamic z-index for an overlay campaign.
964
+ * Stacking order matches priority ranks (Rank 1 at back, Rank 10 at top front).
965
+ */
966
+ declare function getCampaignZIndex(campaign?: any, fallbackType?: CampaignType | string, baseZIndex?: number): number;
967
+
933
968
  declare class AppStorys {
934
969
  private state;
935
970
  private navigateToScreen?;
@@ -955,8 +990,10 @@ declare class AppStorys {
955
990
  set visibility(isVisible: boolean);
956
991
  private ensureInitialized;
957
992
  personalizeText(text: string): string;
993
+ Widget: React.FC<WidgetProps>;
994
+ Widgets: React.FC<WidgetProps>;
958
995
  }
959
996
 
960
997
  declare const instance: AppStorys;
961
998
 
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 };
999
+ export { instance as AppStorys, type AppStorysStore, type Attributes, BASE_OVERLAY_Z_INDEX, 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, DEFAULT_OVERLAY_PRIORITIES, Floater, type InitializationOptions, Modal, type ModalCampaignDetails, type ModalContent, type ModalCtaRedirection, type ModalCtaStyle, type ModalItem, type ModalItemStyling, type ModalMediaType, type ModalTextStyle, Pip, type ResolvedPriority, 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, type WidgetProps, Widget as Widgets, compareCampaignPriority, getCampaignVariantId, getCampaignZIndex, getVariantId, hasVariants, parseCampaignPriority, personalizeText, resolveCampaignVariant, selectVariantByWeight, sortCampaignsByPriority };