@wlloyalty/wll-react-sdk 1.8.0 → 1.9.0
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/README.md +5 -5
- package/dist/index.d.ts +70 -48
- package/dist/native.js +42 -5
- package/dist/native.js.map +1 -1
- package/dist/types/components/atoms/Chip/styles.d.ts +1 -1
- package/dist/types/components/organisms/RewardTile/RewardTile.stories.d.ts +15 -0
- package/dist/types/components/organisms/RewardTile/index.d.ts +1 -0
- package/dist/types/components/organisms/RewardTile/reward-tile-status.d.ts +7 -0
- package/dist/types/types/theme.d.ts +19 -2
- package/dist/types/types/tile.d.ts +4 -0
- package/dist/types/utils/storybookThemes.d.ts +5 -0
- package/dist/web.js +49 -8
- package/dist/web.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://conventionalcommits.org)
|
|
6
6
|
[](https://reactjs.org/)
|
|
7
|
-
[](https://reactnative.dev/)
|
|
8
8
|
|
|
9
9
|
## ✨ Features
|
|
10
10
|
|
|
11
11
|
- 🎨 **Flexible Theming** - Full control over visual styling with automatic color derivation and responsive design system
|
|
12
|
-
- 🧩 **Composable Tiles** - Pre-built components for rewards, points, badges, and tiers that work together seamlessly
|
|
12
|
+
- 🧩 **Composable Tiles** - Pre-built components for rewards, points, badges, banners, venues, and tiers that work together seamlessly
|
|
13
13
|
- 🔌 **Platform Agnostic** - Bring your own navigation and network layer to integrate with any React application
|
|
14
14
|
- 📱 **Mobile First** - Responsive components optimized for both mobile and desktop experiences
|
|
15
15
|
- 🔒 **Secure by Design** - Built-in support for custom API integration through your own backend proxy
|
|
@@ -35,8 +35,8 @@ yarn add @wlloyalty/wll-react-sdk
|
|
|
35
35
|
|
|
36
36
|
The SDK is compatible with:
|
|
37
37
|
|
|
38
|
-
- React:
|
|
39
|
-
- React Native: >=0.
|
|
38
|
+
- React: >=18.0.0
|
|
39
|
+
- React Native: >=0.77.0
|
|
40
40
|
|
|
41
41
|
Please ensure your project meets these version requirements for optimal compatibility.
|
|
42
42
|
|
|
@@ -140,7 +140,7 @@ The script will generate a new component with the proper file structure and boil
|
|
|
140
140
|
|
|
141
141
|
MIT License - See [LICENSE](LICENSE) for more information.
|
|
142
142
|
|
|
143
|
-
Copyright (c)
|
|
143
|
+
Copyright (c) 2026 WLL
|
|
144
144
|
|
|
145
145
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
146
146
|
|
package/dist/index.d.ts
CHANGED
|
@@ -4,52 +4,6 @@ import * as LucideReactIcons from 'lucide-react';
|
|
|
4
4
|
import * as react_native from 'react-native';
|
|
5
5
|
import { ViewProps, ImageSourcePropType, StyleProp, TextProps as TextProps$1, TextStyle, ViewStyle, ImageProps, AccessibilityRole, RefreshControl } from 'react-native';
|
|
6
6
|
|
|
7
|
-
declare const sizes: {
|
|
8
|
-
readonly borderRadiusSm: 15;
|
|
9
|
-
readonly borderRadiusLg: 20;
|
|
10
|
-
readonly borderRadiusButton: 9;
|
|
11
|
-
readonly borderRadiusRounded: 9999;
|
|
12
|
-
readonly xxxs: 4;
|
|
13
|
-
readonly xxs: 8;
|
|
14
|
-
readonly xs: 10;
|
|
15
|
-
readonly sm: 12;
|
|
16
|
-
readonly md: 14;
|
|
17
|
-
readonly lg: 16;
|
|
18
|
-
readonly xl: 20;
|
|
19
|
-
readonly xxl: 24;
|
|
20
|
-
readonly xxxl: 32;
|
|
21
|
-
readonly xxxxl: 40;
|
|
22
|
-
readonly xxxxxl: 60;
|
|
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
|
-
};
|
|
52
|
-
|
|
53
7
|
/**
|
|
54
8
|
* Adds optional children to any component props.
|
|
55
9
|
*/
|
|
@@ -203,6 +157,10 @@ declare class RewardTileConfig {
|
|
|
203
157
|
priority: number;
|
|
204
158
|
availability: Availability;
|
|
205
159
|
purchasable: boolean;
|
|
160
|
+
stockCapacity?: number;
|
|
161
|
+
stockConsumed?: number;
|
|
162
|
+
outOfStockMessage?: string;
|
|
163
|
+
stockRemainingMessage?: string;
|
|
206
164
|
tier: string | null;
|
|
207
165
|
category: RewardCategory;
|
|
208
166
|
discounts: any[];
|
|
@@ -312,6 +270,23 @@ type DerivedColors = {
|
|
|
312
270
|
[K in PercentageKey]: string;
|
|
313
271
|
};
|
|
314
272
|
type DesaturationType = BadgeTileType.Specific | BadgeTileType.Latest;
|
|
273
|
+
type Sizes = {
|
|
274
|
+
borderRadiusSm: number;
|
|
275
|
+
borderRadiusLg: number;
|
|
276
|
+
borderRadiusButton: number;
|
|
277
|
+
borderRadiusRounded: number;
|
|
278
|
+
xxxs: number;
|
|
279
|
+
xxs: number;
|
|
280
|
+
xs: number;
|
|
281
|
+
sm: number;
|
|
282
|
+
md: number;
|
|
283
|
+
lg: number;
|
|
284
|
+
xl: number;
|
|
285
|
+
xxl: number;
|
|
286
|
+
xxxl: number;
|
|
287
|
+
xxxxl: number;
|
|
288
|
+
xxxxxl: number;
|
|
289
|
+
};
|
|
315
290
|
type BaseThemeObject = {
|
|
316
291
|
fontFamily: string;
|
|
317
292
|
accent: string;
|
|
@@ -325,6 +300,7 @@ type BaseThemeObject = {
|
|
|
325
300
|
surface: string;
|
|
326
301
|
surfaceText: string;
|
|
327
302
|
text: string;
|
|
303
|
+
sizes?: Partial<Sizes>;
|
|
328
304
|
};
|
|
329
305
|
type DerivedProperties = {
|
|
330
306
|
accentText: string;
|
|
@@ -338,7 +314,7 @@ type DerivedProperties = {
|
|
|
338
314
|
alphaDerivedText: DerivedColors;
|
|
339
315
|
};
|
|
340
316
|
type ThemeObject = BaseThemeObject & DerivedProperties & {
|
|
341
|
-
|
|
317
|
+
sizes: Sizes;
|
|
342
318
|
};
|
|
343
319
|
type ThemeContextType = {
|
|
344
320
|
theme: ThemeObject;
|
|
@@ -905,6 +881,52 @@ declare const useGetGroupByID: (config: SDKConfig) => (id: string) => Promise<AP
|
|
|
905
881
|
declare const useGetSectionByID: (config: SDKConfig) => (id: string) => Promise<APIResponse<unknown>>;
|
|
906
882
|
declare const useGetTileByID: (config: SDKConfig) => (id: string) => Promise<APIResponse<unknown>>;
|
|
907
883
|
|
|
884
|
+
declare const sizes: {
|
|
885
|
+
readonly borderRadiusSm: 15;
|
|
886
|
+
readonly borderRadiusLg: 20;
|
|
887
|
+
readonly borderRadiusButton: 9;
|
|
888
|
+
readonly borderRadiusRounded: 9999;
|
|
889
|
+
readonly xxxs: 4;
|
|
890
|
+
readonly xxs: 8;
|
|
891
|
+
readonly xs: 10;
|
|
892
|
+
readonly sm: 12;
|
|
893
|
+
readonly md: 14;
|
|
894
|
+
readonly lg: 16;
|
|
895
|
+
readonly xl: 20;
|
|
896
|
+
readonly xxl: 24;
|
|
897
|
+
readonly xxxl: 32;
|
|
898
|
+
readonly xxxxl: 40;
|
|
899
|
+
readonly xxxxxl: 60;
|
|
900
|
+
};
|
|
901
|
+
declare const commonStyles: {
|
|
902
|
+
emptyContainer: {
|
|
903
|
+
flex: number;
|
|
904
|
+
justifyContent: "center";
|
|
905
|
+
alignItems: "center";
|
|
906
|
+
};
|
|
907
|
+
};
|
|
908
|
+
declare const defaultTheme: BaseThemeObject;
|
|
909
|
+
/**
|
|
910
|
+
* Creates appropriate directional margin styles for both web and native platforms.
|
|
911
|
+
* Handles RTL layouts correctly across platforms by using the I18nManager.
|
|
912
|
+
*
|
|
913
|
+
* @param value - The margin value to apply
|
|
914
|
+
* @returns An object with the appropriate margin style property
|
|
915
|
+
*/
|
|
916
|
+
declare const getDirectionalMargin: (value: number) => {
|
|
917
|
+
marginLeft: number;
|
|
918
|
+
marginRight?: undefined;
|
|
919
|
+
marginEnd?: undefined;
|
|
920
|
+
} | {
|
|
921
|
+
marginRight: number;
|
|
922
|
+
marginLeft?: undefined;
|
|
923
|
+
marginEnd?: undefined;
|
|
924
|
+
} | {
|
|
925
|
+
marginEnd: number;
|
|
926
|
+
marginLeft?: undefined;
|
|
927
|
+
marginRight?: undefined;
|
|
928
|
+
};
|
|
929
|
+
|
|
908
930
|
type ThemeName = 'default' | 'dark' | 'modern' | 'warm' | 'forest' | 'sunset';
|
|
909
931
|
declare const themes: Record<ThemeName, BaseThemeObject>;
|
|
910
932
|
declare const themeItems: Array<{
|
|
@@ -1025,4 +1047,4 @@ declare const useInitialGroupFetch: ({ id, setGroupData, }: UseInitialGroupFetch
|
|
|
1025
1047
|
declare const useNavigation: (config: NavigationConfig) => (link: string, ctaTarget: CTALinkTarget) => Promise<void>;
|
|
1026
1048
|
|
|
1027
1049
|
export { BUTTON_SIZE, _default$7 as BadgeTile, BadgeTileConfig, BadgeTileType, _default$6 as BannerTile, BannerTileConfig, BaseBanner, BaseTile, Button, COLOR_CONSTANTS, CTALinkTarget, Carousel, CarouselNavButton, Chip, Column, _default$5 as ContentTile, ContentTileConfig, CoreApiUrl, DIMENSION_MODES, EventEmitter, FullFlex, GRID_GAP, Grid, Group, IS_ANDROID, IS_DESKTOP, IS_IOS, IS_MOBILE, IS_WEB, Icon, Indicator, Layout, LoadingIndicator, MAX_WIDTH, _default$4 as PointsTile, PointsTileConfig, ProgressBar, ProgressIndicator, ProgressType, ProgressiveImage, Reward, _default$3 as RewardCategoryTile, RewardCategoryTileConfig, _default$2 as RewardTile, RewardTileConfig, _default$1 as RoundupTile, RoundupTileConfig, Row, SCREEN_HEIGHT, SCREEN_WIDTH, SLIDE_WIDTH, SMALL_SCREEN_WIDTH, Section, SectionHeader, SectionType, Skeleton, Spacer, StatusVariant, TABLET_SCREEN_WIDTH, Text, TierTileConfig, TierTileType, TierTile as TierTileUpdated, TileContainer, TileHeight, TileType, _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 };
|
|
1028
|
-
export type { APIResponse$1 as APIResponse, Align, AllowedCoreApiUrl, Availability, Badge, BadgeDetail, BaseThemeObject, DerivedColors, DerivedProperties, DesaturationType, EventCallback, EventTypes, FlexDirection, ImagePropsNoSource, Justify, LayoutProps$1 as LayoutProps, NavigationConfig, NavigationType, PercentageKey, ProgessType, RewardCategory, SDKConfig, Size, TGroup, TSection, ThemeContextType, ThemeName, ThemeObject, ThemeProviderProps, TierType, Tile, TileConfig, TileSizeInfo, Variant };
|
|
1050
|
+
export type { APIResponse$1 as APIResponse, Align, AllowedCoreApiUrl, Availability, Badge, BadgeDetail, BaseThemeObject, DerivedColors, DerivedProperties, DesaturationType, EventCallback, EventTypes, FlexDirection, ImagePropsNoSource, Justify, LayoutProps$1 as LayoutProps, NavigationConfig, NavigationType, PercentageKey, ProgessType, RewardCategory, SDKConfig, Size, Sizes, TGroup, TSection, ThemeContextType, ThemeName, ThemeObject, ThemeProviderProps, TierType, Tile, TileConfig, TileSizeInfo, Variant };
|
package/dist/native.js
CHANGED
|
@@ -1072,8 +1072,9 @@ exports.CoreApiUrl = void 0;
|
|
|
1072
1072
|
})(exports.CoreApiUrl || (exports.CoreApiUrl = {}));
|
|
1073
1073
|
var createTheme = function (baseTheme) {
|
|
1074
1074
|
if (baseTheme === void 0) { baseTheme = {}; }
|
|
1075
|
-
var
|
|
1076
|
-
|
|
1075
|
+
var userSizes = baseTheme.sizes, restBaseTheme = __rest(baseTheme, ["sizes"]);
|
|
1076
|
+
var mergedTheme = __assign(__assign({}, defaultTheme), restBaseTheme);
|
|
1077
|
+
return __assign(__assign({}, mergedTheme), { sizes: __assign(__assign({}, sizes), userSizes), derivedBackground: getDerivedColor(mergedTheme.background), primaryText: getReadableTextColor(mergedTheme.primary), accentText: getReadableTextColor(mergedTheme.accent), positiveText: getReadableTextColor(mergedTheme.positive), negativeText: getReadableTextColor(mergedTheme.negative), derivedSurface: getDerivedColorPercentages(mergedTheme.surface), derivedSurfaceText: getDerivedColorPercentages(mergedTheme.surfaceText), alphaDerivedPrimary: getAlphaDerivedColors(mergedTheme.primary), alphaDerivedText: getAlphaDerivedColors(mergedTheme.text) });
|
|
1077
1078
|
};
|
|
1078
1079
|
var WllSdkContext = React.createContext(undefined);
|
|
1079
1080
|
var WllSdkProvider = function (_a) {
|
|
@@ -4136,7 +4137,8 @@ var useRewardTileStyles = function () {
|
|
|
4136
4137
|
paddingHorizontal: useResponsiveValue(theme.sizes.sm, theme.sizes.xxs, isDesktop, isTablet),
|
|
4137
4138
|
},
|
|
4138
4139
|
footer: {
|
|
4139
|
-
|
|
4140
|
+
width: '100%',
|
|
4141
|
+
marginTop: useResponsiveValue(theme.sizes.xxs, theme.sizes.xxxs, isDesktop, isTablet),
|
|
4140
4142
|
},
|
|
4141
4143
|
pointsContainer: {
|
|
4142
4144
|
flexDirection: 'row',
|
|
@@ -4163,6 +4165,10 @@ var useRewardTileStyles = function () {
|
|
|
4163
4165
|
alignItems: 'center',
|
|
4164
4166
|
zIndex: 10,
|
|
4165
4167
|
},
|
|
4168
|
+
statusChip: {
|
|
4169
|
+
flexShrink: 1,
|
|
4170
|
+
marginLeft: 'auto',
|
|
4171
|
+
},
|
|
4166
4172
|
});
|
|
4167
4173
|
};
|
|
4168
4174
|
|
|
@@ -4214,7 +4220,27 @@ var RewardTilePoints = function () {
|
|
|
4214
4220
|
return null;
|
|
4215
4221
|
var calculatedPoints = applyMultiplier(price, pointsMultiplier);
|
|
4216
4222
|
var accessibilityLabel = getPointsLabel('Reward points:', calculatedPoints, pointsPrefix, pointsSuffix);
|
|
4217
|
-
return (jsxRuntimeExports.jsx(reactNative.View, {
|
|
4223
|
+
return (jsxRuntimeExports.jsx(reactNative.View, { testID: "reward-tile-points", role: "article", accessibilityLabel: accessibilityLabel, children: jsxRuntimeExports.jsxs(Row, { align: "center", justify: "start", children: [pointsPrefix ? jsxRuntimeExports.jsx(Text, { variant: "caption", children: pointsPrefix }) : null, jsxRuntimeExports.jsx(Text, { variant: "caption", testID: "reward-tile-points-value", children: calculatedPoints }), pointsSuffix ? (jsxRuntimeExports.jsx(Text, { variant: "caption", style: styles.suffix, children: pointsSuffix })) : null] }) }));
|
|
4224
|
+
};
|
|
4225
|
+
|
|
4226
|
+
/**
|
|
4227
|
+
* Renders availability status for a Reward Tile.
|
|
4228
|
+
*
|
|
4229
|
+
* @returns React.ReactElement or null if the reward is purchasable
|
|
4230
|
+
*/
|
|
4231
|
+
var RewardTileStatus = function () {
|
|
4232
|
+
var styles = useRewardTileStyles();
|
|
4233
|
+
var tileContext = useTileContext();
|
|
4234
|
+
if (!isContextValid(tileContext))
|
|
4235
|
+
return null;
|
|
4236
|
+
var _a = tileContext.configuration, stockCapacity = _a.stockCapacity, stockConsumed = _a.stockConsumed, outOfStockMessage = _a.outOfStockMessage, stockRemainingMessage = _a.stockRemainingMessage;
|
|
4237
|
+
var isOutOfStock = stockCapacity !== undefined &&
|
|
4238
|
+
stockConsumed !== undefined &&
|
|
4239
|
+
stockCapacity <= stockConsumed;
|
|
4240
|
+
var label = isOutOfStock ? outOfStockMessage : stockRemainingMessage;
|
|
4241
|
+
if (!label)
|
|
4242
|
+
return null;
|
|
4243
|
+
return (jsxRuntimeExports.jsx(Chip, { label: label, role: "status", ariaLive: "off", accessibilityLabel: label, testID: "reward-tile-status", variant: exports.StatusVariant.GREY, style: styles.statusChip }));
|
|
4218
4244
|
};
|
|
4219
4245
|
|
|
4220
4246
|
/**
|
|
@@ -4283,7 +4309,17 @@ var RewardTileRoot = function (_a) {
|
|
|
4283
4309
|
return null;
|
|
4284
4310
|
var configuration = tile.configuration;
|
|
4285
4311
|
var artworkOnly = isArtworkOnly(configuration);
|
|
4286
|
-
|
|
4312
|
+
var hasPoints = configuration.showPrice !== false &&
|
|
4313
|
+
configuration.price !== undefined &&
|
|
4314
|
+
configuration.price !== 0;
|
|
4315
|
+
var isOutOfStock = configuration.stockCapacity !== undefined &&
|
|
4316
|
+
configuration.stockConsumed !== undefined &&
|
|
4317
|
+
configuration.stockCapacity <= configuration.stockConsumed;
|
|
4318
|
+
var hasStatus = isOutOfStock
|
|
4319
|
+
? !!configuration.outOfStockMessage
|
|
4320
|
+
: !!configuration.stockRemainingMessage;
|
|
4321
|
+
var hasFooter = hasPoints || hasStatus;
|
|
4322
|
+
return (jsxRuntimeExports.jsxs(BaseTile, { tile: tile, children: [jsxRuntimeExports.jsx(RewardTile.Media, { isArtworkOnly: artworkOnly }), !artworkOnly && (jsxRuntimeExports.jsxs(Layout, { children: [jsxRuntimeExports.jsxs(Row, { justify: "between", align: "center", style: styles.header, children: [jsxRuntimeExports.jsx(RewardTile.Title, {}), jsxRuntimeExports.jsx(RewardTile.Chevron, {})] }), jsxRuntimeExports.jsx(reactNative.View, { style: { width: '100%', maxWidth: '100%', minWidth: 0 }, children: jsxRuntimeExports.jsx(RewardTile.Summary, {}) }), hasFooter && (jsxRuntimeExports.jsxs(Row, { justify: "between", align: "center", style: styles.footer, children: [jsxRuntimeExports.jsx(RewardTile.Points, {}), jsxRuntimeExports.jsx(RewardTile.Status, {})] }))] }))] }));
|
|
4287
4323
|
};
|
|
4288
4324
|
/**
|
|
4289
4325
|
* The RewardTile component with subcomponents attached.
|
|
@@ -4294,6 +4330,7 @@ var RewardTile = Object.assign(RewardTileRoot, {
|
|
|
4294
4330
|
Summary: RewardTileSummary,
|
|
4295
4331
|
Points: RewardTilePoints,
|
|
4296
4332
|
Chevron: RewardTileChevron,
|
|
4333
|
+
Status: RewardTileStatus,
|
|
4297
4334
|
});
|
|
4298
4335
|
var RewardTile$1 = withTileFetching(RewardTile);
|
|
4299
4336
|
|