@wlloyalty/wll-react-sdk 1.4.8 → 1.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -21,6 +21,34 @@ declare const sizes: {
21
21
  readonly xxxxl: 40;
22
22
  readonly xxxxxl: 60;
23
23
  };
24
+ declare const commonStyles: {
25
+ emptyContainer: {
26
+ flex: number;
27
+ justifyContent: "center";
28
+ alignItems: "center";
29
+ };
30
+ };
31
+ declare const defaultTheme: BaseThemeObject;
32
+ /**
33
+ * Creates appropriate directional margin styles for both web and native platforms.
34
+ * Handles RTL layouts correctly across platforms by using the I18nManager.
35
+ *
36
+ * @param value - The margin value to apply
37
+ * @returns An object with the appropriate margin style property
38
+ */
39
+ declare const getDirectionalMargin: (value: number) => {
40
+ marginLeft: number;
41
+ marginRight?: undefined;
42
+ marginEnd?: undefined;
43
+ } | {
44
+ marginRight: number;
45
+ marginLeft?: undefined;
46
+ marginEnd?: undefined;
47
+ } | {
48
+ marginEnd: number;
49
+ marginLeft?: undefined;
50
+ marginRight?: undefined;
51
+ };
24
52
 
25
53
  /**
26
54
  * Adds optional children to any component props.
@@ -109,7 +137,8 @@ declare enum TileType {
109
137
  Badge = "BADGE",
110
138
  RewardCategory = "REWARD_CATEGORY",
111
139
  Tier = "TIER",
112
- Roundup = "ROUND_UP_BALANCE"
140
+ Roundup = "ROUND_UP_BALANCE",
141
+ Venue = "VENUE"
113
142
  }
114
143
  declare enum TileHeight {
115
144
  Half = "HALF",
@@ -188,6 +217,12 @@ declare class RewardTileConfig {
188
217
  pointsPrefix: string | null;
189
218
  pointsSuffix: string | null;
190
219
  }
220
+ declare class VenueTileConfig {
221
+ venueId: string;
222
+ name: string;
223
+ artworkUrl: string;
224
+ description: string;
225
+ }
191
226
  declare enum BadgeTileType {
192
227
  Specific = "SPECIFIC",
193
228
  Latest = "LATEST_EARNED"
@@ -261,7 +296,7 @@ type Tile = {
261
296
  configuration: TileConfig;
262
297
  priority: number;
263
298
  };
264
- declare const getConfigForTileType: (tileType: TileType) => typeof BannerTileConfig | typeof PointsTileConfig | typeof ContentTileConfig | typeof RewardTileConfig | typeof BadgeTileConfig | typeof RewardCategoryTileConfig | typeof TierTileConfig;
299
+ declare const getConfigForTileType: (tileType: TileType) => typeof BannerTileConfig | typeof PointsTileConfig | typeof ContentTileConfig | typeof RewardTileConfig | typeof VenueTileConfig | typeof BadgeTileConfig | typeof RewardCategoryTileConfig | typeof TierTileConfig;
265
300
  type TileConfig = InstanceType<ReturnType<typeof getConfigForTileType>>;
266
301
  type TileSizeInfo = {
267
302
  isFullSize: boolean;
@@ -595,17 +630,17 @@ type WithTileFetchingProps = {
595
630
  type BadgeTileProps = {
596
631
  tile: Tile;
597
632
  };
598
- declare const _default$6: (props: Omit<BadgeTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
633
+ declare const _default$7: (props: Omit<BadgeTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
599
634
 
600
635
  type BannerTileProps = {
601
636
  tile: Tile;
602
637
  };
603
- declare const _default$5: (props: Omit<BannerTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
638
+ declare const _default$6: (props: Omit<BannerTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
604
639
 
605
640
  type ContentTileProps = {
606
641
  tile: Tile;
607
642
  };
608
- declare const _default$4: (props: Omit<ContentTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
643
+ declare const _default$5: (props: Omit<ContentTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
609
644
 
610
645
  type TGroup = {
611
646
  name: string;
@@ -638,17 +673,17 @@ declare const Group: ({ id, enablePullToRefresh, onRefresh }: GroupProps) => Rea
638
673
  type PointsTileProps = {
639
674
  tile: Tile;
640
675
  };
641
- declare const _default$3: (props: Omit<PointsTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
676
+ declare const _default$4: (props: Omit<PointsTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
642
677
 
643
678
  type RewardCategoryTileProps = {
644
679
  tile: Tile;
645
680
  };
646
- declare const _default$2: (props: Omit<RewardCategoryTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
681
+ declare const _default$3: (props: Omit<RewardCategoryTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
647
682
 
648
683
  type RewardTileProps = {
649
684
  tile: Tile;
650
685
  };
651
- declare const _default$1: (props: Omit<RewardTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
686
+ declare const _default$2: (props: Omit<RewardTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
652
687
 
653
688
  type SectionProps = {
654
689
  section?: TSection;
@@ -680,7 +715,12 @@ declare const TierTile: TierTileComponent;
680
715
  type RoundupTileProps = {
681
716
  tile: Tile;
682
717
  };
683
- declare const _default: (props: Omit<RoundupTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
718
+ declare const _default$1: (props: Omit<RoundupTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
719
+
720
+ type VenueTileProps = {
721
+ tile: Tile;
722
+ };
723
+ declare const _default: (props: Omit<VenueTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
684
724
 
685
725
  type NavigationType = 'external' | 'internal' | 'modal';
686
726
  type NavigationHandlerParams = {
@@ -699,11 +739,50 @@ type NavigationConfig = {
699
739
  baseUrl?: string;
700
740
  };
701
741
 
742
+ /**
743
+ * Type definition for event callback functions
744
+ * @typedef {function} EventCallback
745
+ * @param {any} [data] - Optional data passed with the event
746
+ */
747
+ type EventCallback = (data?: any) => void;
702
748
  /**
703
749
  * Supported event types for the SDK event system
704
750
  * @typedef {string} EventTypes
705
751
  */
706
752
  type EventTypes = 'GROUP_DATA_CHANGED' | 'SECTION_DATA_CHANGED' | 'TILE_DATA_CHANGED' | string;
753
+ /**
754
+ * A simple event emitter for handling SDK events
755
+ * Provides a pub-sub mechanism for components to communicate
756
+ */
757
+ declare class EventEmitter {
758
+ /**
759
+ * Map of event types to arrays of callback functions
760
+ * @private
761
+ */
762
+ private events;
763
+ /**
764
+ * Subscribe to an event
765
+ * @param {EventTypes} event - The event type to subscribe to
766
+ * @param {EventCallback} callback - The callback function to execute when the event is emitted
767
+ * @returns {Function} An unsubscribe function that removes this callback when called
768
+ */
769
+ on(event: EventTypes, callback: EventCallback): () => void;
770
+ /**
771
+ * Emit an event with optional data
772
+ * @param {EventTypes} event - The event type to emit
773
+ * @param {any} [data] - Optional data to pass to the event callbacks
774
+ */
775
+ emit(event: EventTypes, data?: any): void;
776
+ /**
777
+ * Remove all event listeners
778
+ * Use this method to clean up when the event emitter is no longer needed
779
+ */
780
+ clear(): void;
781
+ }
782
+ /**
783
+ * Singleton instance of the EventEmitter for use throughout the SDK
784
+ */
785
+ declare const sdkEventEmitter: EventEmitter;
707
786
 
708
787
  declare enum CoreApiUrl {
709
788
  PRODUCTION_EU = "https://api.core.wlloyalty.net/v1",
@@ -720,18 +799,18 @@ type SDKConfig = {
720
799
  locale?: string;
721
800
  coreApiUrl: AllowedCoreApiUrl;
722
801
  };
723
- type Fetcher = <T>(endpoint: string, options?: RequestInit) => Promise<APIResponse<T>>;
724
- type APIResponse<T> = {
802
+ type Fetcher = <T>(endpoint: string, options?: RequestInit) => Promise<APIResponse$1<T>>;
803
+ type APIResponse$1<T> = {
725
804
  status: 'success' | 'error';
726
805
  data: T | null;
727
806
  error?: string;
728
807
  };
729
808
  type WllSdkContextType = ThemeContextType & {
730
- getGroupByID: (id: string) => Promise<APIResponse<TGroup>>;
731
- getSectionByID: (id: string) => Promise<APIResponse<TSection>>;
732
- getTileByID: (id: string) => Promise<APIResponse<Tile>>;
809
+ getGroupByID: (id: string) => Promise<APIResponse$1<TGroup>>;
810
+ getSectionByID: (id: string) => Promise<APIResponse$1<TSection>>;
811
+ getTileByID: (id: string) => Promise<APIResponse$1<Tile>>;
733
812
  handleNavigation: (link: string, target: CTALinkTarget) => Promise<void>;
734
- refreshGroup: (id: string) => Promise<APIResponse<TGroup>>;
813
+ refreshGroup: (id: string) => Promise<APIResponse$1<TGroup>>;
735
814
  notifyDataChange: (eventType: EventTypes, data?: any) => void;
736
815
  subscribeToDataChange: (eventType: EventTypes, callback: (data?: any) => void) => () => void;
737
816
  } & Readonly<{
@@ -765,4 +844,179 @@ declare function usePullToRefresh({ onRefresh, refreshing: externalRefreshing, }
765
844
  handleRefresh: () => Promise<void>;
766
845
  };
767
846
 
768
- export { type APIResponse, type Align, type AllowedCoreApiUrl, type Availability, type Badge, type BadgeDetail, _default$6 as BadgeTile, BadgeTileConfig, BadgeTileType, _default$5 as BannerTile, BannerTileConfig, BaseBanner, type BaseThemeObject, BaseTile, Button, CTALinkTarget, Carousel, CarouselNavButton, Chip, Column, _default$4 as ContentTile, ContentTileConfig, CoreApiUrl, type DerivedColors, type DerivedProperties, type DesaturationType, type FlexDirection, FullFlex, Grid, Group, Icon, type ImagePropsNoSource, Indicator, type Justify, Layout, type LayoutProps$1 as LayoutProps, LoadingIndicator, type NavigationConfig, type NavigationType, type PercentageKey, _default$3 as PointsTile, PointsTileConfig, type ProgessType, ProgressBar, ProgressIndicator, ProgressType, ProgressiveImage, Reward, type RewardCategory, _default$2 as RewardCategoryTile, RewardCategoryTileConfig, _default$1 as RewardTile, RewardTileConfig, _default as RoundupTile, RoundupTileConfig, Row, type SDKConfig, Section, SectionHeader, SectionType, type Size, Skeleton, Spacer, StatusVariant, type TGroup, type TSection, Text, type ThemeContextType, type ThemeObject, type ThemeProviderProps, TierTileConfig, TierTileType, TierTile as TierTileUpdated, type TierType, type Tile, type TileConfig, TileContainer, TileHeight, type TileSizeInfo, TileType, type Variant, WllSdkProvider, alignMap, justifyMap, useInvalidateData, usePullToRefresh, useWllSdk };
847
+ declare const IS_WEB: boolean;
848
+ declare const IS_IOS: boolean;
849
+ declare const IS_ANDROID: boolean;
850
+ declare const IS_MOBILE: boolean;
851
+ declare const IS_DESKTOP: boolean;
852
+ declare const SCREEN_WIDTH: number;
853
+ declare const SCREEN_HEIGHT: number;
854
+
855
+ declare const DIMENSION_MODES: {
856
+ DESKTOP: "desktop";
857
+ TABLET: "tablet";
858
+ MOBILE: "mobile";
859
+ };
860
+ declare const TABLET_SCREEN_WIDTH = 768;
861
+ declare const SMALL_SCREEN_WIDTH = 480;
862
+
863
+ declare const COLOR_CONSTANTS: {
864
+ readonly MINIMUM_CONTRAST_RATIO: 2;
865
+ readonly DEFAULT_LIGHTNESS_ADJUSTMENT: 0.2;
866
+ readonly DESATURATION_LIGHTEN_AMOUNT: 0.2 | 0.8;
867
+ readonly DEFAULT_COLOR: "#FFFFFF";
868
+ };
869
+
870
+ declare const GRID_GAP = 16;
871
+
872
+ declare const MAX_WIDTH = 1080;
873
+ declare const SLIDE_WIDTH = 1080;
874
+ declare const BUTTON_SIZE = 42;
875
+
876
+ type APIResponse<T> = {
877
+ status: 'success' | 'fail' | 'error';
878
+ data: T | null;
879
+ error?: string;
880
+ };
881
+ declare const useCreateRequestOptions: (config: SDKConfig) => (options?: RequestInit) => {
882
+ headers: Headers;
883
+ body?: BodyInit | null;
884
+ cache?: RequestCache;
885
+ credentials?: RequestCredentials;
886
+ integrity?: string;
887
+ keepalive?: boolean;
888
+ method?: string;
889
+ mode?: RequestMode;
890
+ priority?: RequestPriority;
891
+ redirect?: RequestRedirect;
892
+ referrer?: string;
893
+ referrerPolicy?: ReferrerPolicy;
894
+ signal?: AbortSignal | null;
895
+ window?: null;
896
+ } | undefined;
897
+ declare const useMakeRequest: (config: SDKConfig) => <T>(url: string) => Promise<APIResponse<T>>;
898
+ declare const createResourceGetter: (resource: string, includeHydrate?: boolean) => (config: SDKConfig) => (id: string) => Promise<APIResponse<unknown>>;
899
+ declare const useGetGroupByID: (config: SDKConfig) => (id: string) => Promise<APIResponse<unknown>>;
900
+ declare const useGetSectionByID: (config: SDKConfig) => (id: string) => Promise<APIResponse<unknown>>;
901
+ declare const useGetTileByID: (config: SDKConfig) => (id: string) => Promise<APIResponse<unknown>>;
902
+
903
+ type ThemeName = 'default' | 'dark' | 'modern' | 'warm' | 'forest' | 'sunset';
904
+ declare const themes: Record<ThemeName, BaseThemeObject>;
905
+ declare const themeItems: Array<{
906
+ value: ThemeName;
907
+ title: string;
908
+ }>;
909
+
910
+ /**
911
+ * Validates a theme object to ensure all required colors are present and valid
912
+ * @param theme - Partial theme object to validate
913
+ * @returns Boolean indicating if theme is valid
914
+ */
915
+ declare const validateTheme: (theme: Partial<BaseThemeObject>) => boolean;
916
+ /**
917
+ * Returns a derived color based on the background darkness
918
+ * @param color - Base color to derive from
919
+ * @returns Derived color string or default color if invalid
920
+ */
921
+ declare const getDerivedColor: (color: string) => string;
922
+ /**
923
+ * Determines the most readable text color (black or white) for a given background
924
+ * @param backgroundColor - Background color to check against
925
+ * @returns Hex color string for text
926
+ */
927
+ declare const getReadableTextColor: (backgroundColor: string) => string;
928
+ /**
929
+ * Generates a set of colors with varying lightness based on the base color
930
+ * @param color - Base color to derive from
931
+ * @returns Object containing derived colors at different lightness levels
932
+ */
933
+ declare const getDerivedColorPercentages: (color: string) => DerivedColors;
934
+ /**
935
+ * Generates a set of colors with varying alpha values
936
+ * @param color - Base color to derive from
937
+ * @returns Object containing derived colors at different alpha levels
938
+ */
939
+ declare const getAlphaDerivedColors: (color: string) => DerivedColors;
940
+ /**
941
+ * Determines if a color should be desaturated based on type and count
942
+ * @param type - Type of desaturation to apply
943
+ * @param count - Count value affecting desaturation
944
+ * @returns Boolean indicating if color should be desaturated
945
+ */
946
+ declare const shouldDesaturate: (type: DesaturationType, count: number) => boolean;
947
+ /**
948
+ * Desaturates a color and lightens it
949
+ * @param color - Color to desaturate
950
+ * @returns Desaturated color string or default color if invalid
951
+ */
952
+ declare const desaturateColor: (color: string) => string;
953
+ /**
954
+ * Gets the appropriate state color based on type and count
955
+ * @param baseColor - Base color to process
956
+ * @param type - Type of state
957
+ * @param count - Count affecting the state
958
+ * @returns Processed color string
959
+ */
960
+ declare const getStateColor: (baseColor: string, type: DesaturationType, count: number) => string;
961
+
962
+ /**
963
+ * Sorts tiles by priority (higher priority first) and maintains original order for equal priorities
964
+ * @param tiles Array of tiles to sort
965
+ * @returns Sorted array of tiles
966
+ */
967
+ declare const sortByPriority: <T extends Pick<Tile, "priority">>(tiles: T[]) => T[];
968
+ /**
969
+ * Transforms locale to a locale that is supported by the browser
970
+ * @param locale Two-letter locale code to transform (en, fr, etc.)
971
+ * @returns Full locale string (e.g., en-GB, fr-FR)
972
+ */
973
+ declare const transformLocale: (locale?: string | null) => string;
974
+ /**
975
+ * Formats a date string to a localized date string based on user locale
976
+ * @param date Date string to format
977
+ * @param userLocale User's locale (defaults to 'en')
978
+ * @returns Formatted date string or fallback message
979
+ */
980
+ declare const handleLastEarnedDate: (date?: string, userLocale?: string) => string;
981
+
982
+ declare const getResponsiveValue: (desktopValue: number, mobileValue: number, isDesktop: boolean, isTablet: boolean) => number;
983
+ declare const useResponsiveValue: (desktopValue: number, mobileValue: number, isDesktop: boolean, isTablet: boolean) => number;
984
+
985
+ type DimensionMode = 'desktop' | 'tablet' | 'mobile';
986
+ type WindowDimensions = {
987
+ width: number;
988
+ height: number;
989
+ };
990
+
991
+ declare function getDimensionMode(window: WindowDimensions): DimensionMode;
992
+ declare function useResponsive(): {
993
+ dimensionMode: DimensionMode;
994
+ isDesktop: boolean;
995
+ isTablet: boolean;
996
+ isMobile: boolean;
997
+ };
998
+
999
+ declare const useTileSize: (tile: Tile) => {
1000
+ isFullSize: boolean;
1001
+ isHalfSize: boolean;
1002
+ };
1003
+
1004
+ type UseGroupRefreshProps = {
1005
+ id: string;
1006
+ enabled?: boolean;
1007
+ setGroupData: (g: TGroup) => void;
1008
+ };
1009
+ declare const useGroupRefresh: ({ id, enabled, setGroupData, }: UseGroupRefreshProps) => void;
1010
+
1011
+ type UseInitialGroupFetchProps = {
1012
+ id: string;
1013
+ setGroupData: (group: TGroup) => void;
1014
+ };
1015
+ declare const useInitialGroupFetch: ({ id, setGroupData, }: UseInitialGroupFetchProps) => {
1016
+ isLoading: boolean;
1017
+ error: string | null;
1018
+ };
1019
+
1020
+ declare const useNavigation: (config: NavigationConfig) => (link: string, ctaTarget: CTALinkTarget) => Promise<void>;
1021
+
1022
+ export { type APIResponse$1 as APIResponse, type Align, type AllowedCoreApiUrl, type Availability, BUTTON_SIZE, type Badge, type BadgeDetail, _default$7 as BadgeTile, BadgeTileConfig, BadgeTileType, _default$6 as BannerTile, BannerTileConfig, BaseBanner, type BaseThemeObject, BaseTile, Button, COLOR_CONSTANTS, CTALinkTarget, Carousel, CarouselNavButton, Chip, Column, _default$5 as ContentTile, ContentTileConfig, CoreApiUrl, DIMENSION_MODES, type DerivedColors, type DerivedProperties, type DesaturationType, type EventCallback, EventEmitter, type EventTypes, type FlexDirection, FullFlex, GRID_GAP, Grid, Group, IS_ANDROID, IS_DESKTOP, IS_IOS, IS_MOBILE, IS_WEB, Icon, type ImagePropsNoSource, Indicator, type Justify, Layout, type LayoutProps$1 as LayoutProps, LoadingIndicator, MAX_WIDTH, type NavigationConfig, type NavigationType, type PercentageKey, _default$4 as PointsTile, PointsTileConfig, type ProgessType, ProgressBar, ProgressIndicator, ProgressType, ProgressiveImage, Reward, type RewardCategory, _default$3 as RewardCategoryTile, RewardCategoryTileConfig, _default$2 as RewardTile, RewardTileConfig, _default$1 as RoundupTile, RoundupTileConfig, Row, SCREEN_HEIGHT, SCREEN_WIDTH, type SDKConfig, SLIDE_WIDTH, SMALL_SCREEN_WIDTH, Section, SectionHeader, SectionType, type Size, Skeleton, Spacer, StatusVariant, TABLET_SCREEN_WIDTH, type TGroup, type TSection, Text, type ThemeContextType, type ThemeName, type ThemeObject, type ThemeProviderProps, TierTileConfig, TierTileType, TierTile as TierTileUpdated, type TierType, type Tile, type TileConfig, TileContainer, TileHeight, type TileSizeInfo, TileType, type Variant, _default as VenueTile, VenueTileConfig, WllSdkProvider, alignMap, commonStyles, createResourceGetter, defaultTheme, desaturateColor, getAlphaDerivedColors, getDerivedColor, getDerivedColorPercentages, getDimensionMode, getDirectionalMargin, getReadableTextColor, getResponsiveValue, getStateColor, handleLastEarnedDate, justifyMap, sdkEventEmitter, shouldDesaturate, sizes, sortByPriority, themeItems, themes, transformLocale, useCreateRequestOptions, useGetGroupByID, useGetSectionByID, useGetTileByID, useGroupRefresh, useInitialGroupFetch, useInvalidateData, useMakeRequest, useNavigation, usePullToRefresh, useResponsive, useResponsiveValue, useTileSize, useWllSdk, validateTheme };