@wlloyalty/wll-react-sdk 1.4.8 → 1.4.10

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;
@@ -318,9 +353,10 @@ type ButtonProps = {
318
353
  disabled?: boolean;
319
354
  accessibilityLabel?: string;
320
355
  accessibilityHint?: string;
356
+ icon?: React$1.ReactNode;
321
357
  testID?: string;
322
358
  };
323
- declare const Button: ({ title, onPress, variant, disabled, accessibilityLabel, accessibilityHint, testID, }: ButtonProps) => React$1.ReactElement;
359
+ declare const Button: ({ title, onPress, variant, disabled, accessibilityLabel, accessibilityHint, icon, testID, }: ButtonProps) => React$1.ReactElement;
324
360
 
325
361
  type IconName = keyof typeof LucideReactIcons;
326
362
  type IconProps = {
@@ -595,17 +631,17 @@ type WithTileFetchingProps = {
595
631
  type BadgeTileProps = {
596
632
  tile: Tile;
597
633
  };
598
- declare const _default$6: (props: Omit<BadgeTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
634
+ declare const _default$7: (props: Omit<BadgeTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
599
635
 
600
636
  type BannerTileProps = {
601
637
  tile: Tile;
602
638
  };
603
- declare const _default$5: (props: Omit<BannerTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
639
+ declare const _default$6: (props: Omit<BannerTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
604
640
 
605
641
  type ContentTileProps = {
606
642
  tile: Tile;
607
643
  };
608
- declare const _default$4: (props: Omit<ContentTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
644
+ declare const _default$5: (props: Omit<ContentTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
609
645
 
610
646
  type TGroup = {
611
647
  name: string;
@@ -638,17 +674,17 @@ declare const Group: ({ id, enablePullToRefresh, onRefresh }: GroupProps) => Rea
638
674
  type PointsTileProps = {
639
675
  tile: Tile;
640
676
  };
641
- declare const _default$3: (props: Omit<PointsTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
677
+ declare const _default$4: (props: Omit<PointsTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
642
678
 
643
679
  type RewardCategoryTileProps = {
644
680
  tile: Tile;
645
681
  };
646
- declare const _default$2: (props: Omit<RewardCategoryTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
682
+ declare const _default$3: (props: Omit<RewardCategoryTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
647
683
 
648
684
  type RewardTileProps = {
649
685
  tile: Tile;
650
686
  };
651
- declare const _default$1: (props: Omit<RewardTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
687
+ declare const _default$2: (props: Omit<RewardTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
652
688
 
653
689
  type SectionProps = {
654
690
  section?: TSection;
@@ -680,7 +716,12 @@ declare const TierTile: TierTileComponent;
680
716
  type RoundupTileProps = {
681
717
  tile: Tile;
682
718
  };
683
- declare const _default: (props: Omit<RoundupTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
719
+ declare const _default$1: (props: Omit<RoundupTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
720
+
721
+ type VenueTileProps = {
722
+ tile: Tile;
723
+ };
724
+ declare const _default: (props: Omit<VenueTileProps, "tile"> & WithTileFetchingProps) => React__default.JSX.Element;
684
725
 
685
726
  type NavigationType = 'external' | 'internal' | 'modal';
686
727
  type NavigationHandlerParams = {
@@ -699,11 +740,50 @@ type NavigationConfig = {
699
740
  baseUrl?: string;
700
741
  };
701
742
 
743
+ /**
744
+ * Type definition for event callback functions
745
+ * @typedef {function} EventCallback
746
+ * @param {any} [data] - Optional data passed with the event
747
+ */
748
+ type EventCallback = (data?: any) => void;
702
749
  /**
703
750
  * Supported event types for the SDK event system
704
751
  * @typedef {string} EventTypes
705
752
  */
706
753
  type EventTypes = 'GROUP_DATA_CHANGED' | 'SECTION_DATA_CHANGED' | 'TILE_DATA_CHANGED' | string;
754
+ /**
755
+ * A simple event emitter for handling SDK events
756
+ * Provides a pub-sub mechanism for components to communicate
757
+ */
758
+ declare class EventEmitter {
759
+ /**
760
+ * Map of event types to arrays of callback functions
761
+ * @private
762
+ */
763
+ private events;
764
+ /**
765
+ * Subscribe to an event
766
+ * @param {EventTypes} event - The event type to subscribe to
767
+ * @param {EventCallback} callback - The callback function to execute when the event is emitted
768
+ * @returns {Function} An unsubscribe function that removes this callback when called
769
+ */
770
+ on(event: EventTypes, callback: EventCallback): () => void;
771
+ /**
772
+ * Emit an event with optional data
773
+ * @param {EventTypes} event - The event type to emit
774
+ * @param {any} [data] - Optional data to pass to the event callbacks
775
+ */
776
+ emit(event: EventTypes, data?: any): void;
777
+ /**
778
+ * Remove all event listeners
779
+ * Use this method to clean up when the event emitter is no longer needed
780
+ */
781
+ clear(): void;
782
+ }
783
+ /**
784
+ * Singleton instance of the EventEmitter for use throughout the SDK
785
+ */
786
+ declare const sdkEventEmitter: EventEmitter;
707
787
 
708
788
  declare enum CoreApiUrl {
709
789
  PRODUCTION_EU = "https://api.core.wlloyalty.net/v1",
@@ -720,18 +800,18 @@ type SDKConfig = {
720
800
  locale?: string;
721
801
  coreApiUrl: AllowedCoreApiUrl;
722
802
  };
723
- type Fetcher = <T>(endpoint: string, options?: RequestInit) => Promise<APIResponse<T>>;
724
- type APIResponse<T> = {
803
+ type Fetcher = <T>(endpoint: string, options?: RequestInit) => Promise<APIResponse$1<T>>;
804
+ type APIResponse$1<T> = {
725
805
  status: 'success' | 'error';
726
806
  data: T | null;
727
807
  error?: string;
728
808
  };
729
809
  type WllSdkContextType = ThemeContextType & {
730
- getGroupByID: (id: string) => Promise<APIResponse<TGroup>>;
731
- getSectionByID: (id: string) => Promise<APIResponse<TSection>>;
732
- getTileByID: (id: string) => Promise<APIResponse<Tile>>;
810
+ getGroupByID: (id: string) => Promise<APIResponse$1<TGroup>>;
811
+ getSectionByID: (id: string) => Promise<APIResponse$1<TSection>>;
812
+ getTileByID: (id: string) => Promise<APIResponse$1<Tile>>;
733
813
  handleNavigation: (link: string, target: CTALinkTarget) => Promise<void>;
734
- refreshGroup: (id: string) => Promise<APIResponse<TGroup>>;
814
+ refreshGroup: (id: string) => Promise<APIResponse$1<TGroup>>;
735
815
  notifyDataChange: (eventType: EventTypes, data?: any) => void;
736
816
  subscribeToDataChange: (eventType: EventTypes, callback: (data?: any) => void) => () => void;
737
817
  } & Readonly<{
@@ -765,4 +845,179 @@ declare function usePullToRefresh({ onRefresh, refreshing: externalRefreshing, }
765
845
  handleRefresh: () => Promise<void>;
766
846
  };
767
847
 
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 };
848
+ declare const IS_WEB: boolean;
849
+ declare const IS_IOS: boolean;
850
+ declare const IS_ANDROID: boolean;
851
+ declare const IS_MOBILE: boolean;
852
+ declare const IS_DESKTOP: boolean;
853
+ declare const SCREEN_WIDTH: number;
854
+ declare const SCREEN_HEIGHT: number;
855
+
856
+ declare const DIMENSION_MODES: {
857
+ DESKTOP: "desktop";
858
+ TABLET: "tablet";
859
+ MOBILE: "mobile";
860
+ };
861
+ declare const TABLET_SCREEN_WIDTH = 768;
862
+ declare const SMALL_SCREEN_WIDTH = 480;
863
+
864
+ declare const COLOR_CONSTANTS: {
865
+ readonly MINIMUM_CONTRAST_RATIO: 2;
866
+ readonly DEFAULT_LIGHTNESS_ADJUSTMENT: 0.2;
867
+ readonly DESATURATION_LIGHTEN_AMOUNT: 0.2 | 0.8;
868
+ readonly DEFAULT_COLOR: "#FFFFFF";
869
+ };
870
+
871
+ declare const GRID_GAP = 16;
872
+
873
+ declare const MAX_WIDTH = 1080;
874
+ declare const SLIDE_WIDTH = 1080;
875
+ declare const BUTTON_SIZE = 42;
876
+
877
+ type APIResponse<T> = {
878
+ status: 'success' | 'fail' | 'error';
879
+ data: T | null;
880
+ error?: string;
881
+ };
882
+ declare const useCreateRequestOptions: (config: SDKConfig) => (options?: RequestInit) => {
883
+ headers: Headers;
884
+ body?: BodyInit | null;
885
+ cache?: RequestCache;
886
+ credentials?: RequestCredentials;
887
+ integrity?: string;
888
+ keepalive?: boolean;
889
+ method?: string;
890
+ mode?: RequestMode;
891
+ priority?: RequestPriority;
892
+ redirect?: RequestRedirect;
893
+ referrer?: string;
894
+ referrerPolicy?: ReferrerPolicy;
895
+ signal?: AbortSignal | null;
896
+ window?: null;
897
+ } | undefined;
898
+ declare const useMakeRequest: (config: SDKConfig) => <T>(url: string) => Promise<APIResponse<T>>;
899
+ declare const createResourceGetter: (resource: string, includeHydrate?: boolean) => (config: SDKConfig) => (id: string) => Promise<APIResponse<unknown>>;
900
+ declare const useGetGroupByID: (config: SDKConfig) => (id: string) => Promise<APIResponse<unknown>>;
901
+ declare const useGetSectionByID: (config: SDKConfig) => (id: string) => Promise<APIResponse<unknown>>;
902
+ declare const useGetTileByID: (config: SDKConfig) => (id: string) => Promise<APIResponse<unknown>>;
903
+
904
+ type ThemeName = 'default' | 'dark' | 'modern' | 'warm' | 'forest' | 'sunset';
905
+ declare const themes: Record<ThemeName, BaseThemeObject>;
906
+ declare const themeItems: Array<{
907
+ value: ThemeName;
908
+ title: string;
909
+ }>;
910
+
911
+ /**
912
+ * Validates a theme object to ensure all required colors are present and valid
913
+ * @param theme - Partial theme object to validate
914
+ * @returns Boolean indicating if theme is valid
915
+ */
916
+ declare const validateTheme: (theme: Partial<BaseThemeObject>) => boolean;
917
+ /**
918
+ * Returns a derived color based on the background darkness
919
+ * @param color - Base color to derive from
920
+ * @returns Derived color string or default color if invalid
921
+ */
922
+ declare const getDerivedColor: (color: string) => string;
923
+ /**
924
+ * Determines the most readable text color (black or white) for a given background
925
+ * @param backgroundColor - Background color to check against
926
+ * @returns Hex color string for text
927
+ */
928
+ declare const getReadableTextColor: (backgroundColor: string) => string;
929
+ /**
930
+ * Generates a set of colors with varying lightness based on the base color
931
+ * @param color - Base color to derive from
932
+ * @returns Object containing derived colors at different lightness levels
933
+ */
934
+ declare const getDerivedColorPercentages: (color: string) => DerivedColors;
935
+ /**
936
+ * Generates a set of colors with varying alpha values
937
+ * @param color - Base color to derive from
938
+ * @returns Object containing derived colors at different alpha levels
939
+ */
940
+ declare const getAlphaDerivedColors: (color: string) => DerivedColors;
941
+ /**
942
+ * Determines if a color should be desaturated based on type and count
943
+ * @param type - Type of desaturation to apply
944
+ * @param count - Count value affecting desaturation
945
+ * @returns Boolean indicating if color should be desaturated
946
+ */
947
+ declare const shouldDesaturate: (type: DesaturationType, count: number) => boolean;
948
+ /**
949
+ * Desaturates a color and lightens it
950
+ * @param color - Color to desaturate
951
+ * @returns Desaturated color string or default color if invalid
952
+ */
953
+ declare const desaturateColor: (color: string) => string;
954
+ /**
955
+ * Gets the appropriate state color based on type and count
956
+ * @param baseColor - Base color to process
957
+ * @param type - Type of state
958
+ * @param count - Count affecting the state
959
+ * @returns Processed color string
960
+ */
961
+ declare const getStateColor: (baseColor: string, type: DesaturationType, count: number) => string;
962
+
963
+ /**
964
+ * Sorts tiles by priority (higher priority first) and maintains original order for equal priorities
965
+ * @param tiles Array of tiles to sort
966
+ * @returns Sorted array of tiles
967
+ */
968
+ declare const sortByPriority: <T extends Pick<Tile, "priority">>(tiles: T[]) => T[];
969
+ /**
970
+ * Transforms locale to a locale that is supported by the browser
971
+ * @param locale Two-letter locale code to transform (en, fr, etc.)
972
+ * @returns Full locale string (e.g., en-GB, fr-FR)
973
+ */
974
+ declare const transformLocale: (locale?: string | null) => string;
975
+ /**
976
+ * Formats a date string to a localized date string based on user locale
977
+ * @param date Date string to format
978
+ * @param userLocale User's locale (defaults to 'en')
979
+ * @returns Formatted date string or fallback message
980
+ */
981
+ declare const handleLastEarnedDate: (date?: string, userLocale?: string) => string;
982
+
983
+ declare const getResponsiveValue: (desktopValue: number, mobileValue: number, isDesktop: boolean, isTablet: boolean) => number;
984
+ declare const useResponsiveValue: (desktopValue: number, mobileValue: number, isDesktop: boolean, isTablet: boolean) => number;
985
+
986
+ type DimensionMode = 'desktop' | 'tablet' | 'mobile';
987
+ type WindowDimensions = {
988
+ width: number;
989
+ height: number;
990
+ };
991
+
992
+ declare function getDimensionMode(window: WindowDimensions): DimensionMode;
993
+ declare function useResponsive(): {
994
+ dimensionMode: DimensionMode;
995
+ isDesktop: boolean;
996
+ isTablet: boolean;
997
+ isMobile: boolean;
998
+ };
999
+
1000
+ declare const useTileSize: (tile: Tile) => {
1001
+ isFullSize: boolean;
1002
+ isHalfSize: boolean;
1003
+ };
1004
+
1005
+ type UseGroupRefreshProps = {
1006
+ id: string;
1007
+ enabled?: boolean;
1008
+ setGroupData: (g: TGroup) => void;
1009
+ };
1010
+ declare const useGroupRefresh: ({ id, enabled, setGroupData, }: UseGroupRefreshProps) => void;
1011
+
1012
+ type UseInitialGroupFetchProps = {
1013
+ id: string;
1014
+ setGroupData: (group: TGroup) => void;
1015
+ };
1016
+ declare const useInitialGroupFetch: ({ id, setGroupData, }: UseInitialGroupFetchProps) => {
1017
+ isLoading: boolean;
1018
+ error: string | null;
1019
+ };
1020
+
1021
+ declare const useNavigation: (config: NavigationConfig) => (link: string, ctaTarget: CTALinkTarget) => Promise<void>;
1022
+
1023
+ 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 };