@wlloyalty/wll-react-sdk 1.0.103 → 1.0.104
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 +1 -0
- package/dist/native.js +83 -42
- package/dist/native.js.map +1 -1
- package/dist/types/mocks/tiles/badgeTile.d.ts +1 -0
- package/dist/types/types/tile.d.ts +1 -0
- package/dist/types/utils/transforms.d.ts +13 -0
- package/dist/web.js +85 -43
- package/dist/web.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,3 +5,16 @@ import { Tile } from '../types/tile';
|
|
|
5
5
|
* @returns Sorted array of tiles
|
|
6
6
|
*/
|
|
7
7
|
export declare const sortByPriority: <T extends Pick<Tile, "priority">>(tiles: T[]) => T[];
|
|
8
|
+
/**
|
|
9
|
+
* Transforms locale to a locale that is supported by the browser
|
|
10
|
+
* @param locale Two-letter locale code to transform (en, fr, etc.)
|
|
11
|
+
* @returns Full locale string (e.g., en-GB, fr-FR)
|
|
12
|
+
*/
|
|
13
|
+
export declare const transformLocale: (locale?: string | null) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Formats a date string to a localized date string based on user locale
|
|
16
|
+
* @param date Date string to format
|
|
17
|
+
* @param userLocale User's locale (defaults to 'en')
|
|
18
|
+
* @returns Formatted date string or fallback message
|
|
19
|
+
*/
|
|
20
|
+
export declare const handleLastEarnedDate: (date?: string, userLocale?: string) => string;
|
package/dist/web.js
CHANGED
|
@@ -19263,7 +19263,7 @@ var BaseTileBody = function (props) {
|
|
|
19263
19263
|
return /*#__PURE__*/React.createElement(Text, __assign({
|
|
19264
19264
|
variant: "body"
|
|
19265
19265
|
}, props, {
|
|
19266
|
-
|
|
19266
|
+
role: "article",
|
|
19267
19267
|
accessibilityLabel: body,
|
|
19268
19268
|
numberOfLines: getNumberOfLines(),
|
|
19269
19269
|
testID: "tile-body"
|
|
@@ -19387,7 +19387,7 @@ var BaseTileContent = function (_a) {
|
|
|
19387
19387
|
justifyContent: 'center',
|
|
19388
19388
|
height: !artworkUrl ? '100%' : undefined
|
|
19389
19389
|
}],
|
|
19390
|
-
|
|
19390
|
+
role: "none"
|
|
19391
19391
|
}, children);
|
|
19392
19392
|
};
|
|
19393
19393
|
|
|
@@ -19415,7 +19415,7 @@ var BaseTileHeader = function (_a) {
|
|
|
19415
19415
|
return /*#__PURE__*/React.createElement(View$2, {
|
|
19416
19416
|
style: combinedStyle,
|
|
19417
19417
|
testID: "tile-header",
|
|
19418
|
-
|
|
19418
|
+
role: "heading"
|
|
19419
19419
|
}, children);
|
|
19420
19420
|
};
|
|
19421
19421
|
|
|
@@ -19441,7 +19441,7 @@ var BaseTileMedia = function (props) {
|
|
|
19441
19441
|
testID: "tile-media",
|
|
19442
19442
|
style: [props.style, baseStyles.media, styles.media],
|
|
19443
19443
|
alt: "Content image".concat(title ? " for ".concat(title) : ''),
|
|
19444
|
-
|
|
19444
|
+
role: "img"
|
|
19445
19445
|
}));
|
|
19446
19446
|
};
|
|
19447
19447
|
|
|
@@ -19467,7 +19467,7 @@ var BaseTileTitle = function () {
|
|
|
19467
19467
|
if (isHalfSize && artworkUrl || !title) return null;
|
|
19468
19468
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
|
|
19469
19469
|
variant: "title",
|
|
19470
|
-
|
|
19470
|
+
role: "heading",
|
|
19471
19471
|
accessibilityLabel: title,
|
|
19472
19472
|
numberOfLines: 1,
|
|
19473
19473
|
testID: "tile-title"
|
|
@@ -19535,7 +19535,7 @@ var BaseTileContainer = function (_a) {
|
|
|
19535
19535
|
onPress: handlePress,
|
|
19536
19536
|
disabled: tile.type !== 'REWARD' && tile.type !== 'REWARD_CATEGORY' && !ctaLink,
|
|
19537
19537
|
accessible: true,
|
|
19538
|
-
|
|
19538
|
+
role: "button",
|
|
19539
19539
|
accessibilityLabel: "".concat(title).concat(ctaLink ? ' - Click to open' : ''),
|
|
19540
19540
|
accessibilityState: {
|
|
19541
19541
|
disabled: !ctaLink
|
|
@@ -19798,6 +19798,63 @@ function withTileFetching(WrappedComponent) {
|
|
|
19798
19798
|
};
|
|
19799
19799
|
}
|
|
19800
19800
|
|
|
19801
|
+
/**
|
|
19802
|
+
* Sorts tiles by priority (higher priority first) and maintains original order for equal priorities
|
|
19803
|
+
* @param tiles Array of tiles to sort
|
|
19804
|
+
* @returns Sorted array of tiles
|
|
19805
|
+
*/
|
|
19806
|
+
var sortByPriority = function (tiles) {
|
|
19807
|
+
return __spreadArray([], tiles, true).sort(function (a, b) {
|
|
19808
|
+
// Sort by priority (higher priority first)
|
|
19809
|
+
if (a.priority !== b.priority) {
|
|
19810
|
+
return b.priority - a.priority;
|
|
19811
|
+
}
|
|
19812
|
+
// If priorities are equal, maintain original order
|
|
19813
|
+
return tiles.indexOf(a) - tiles.indexOf(b);
|
|
19814
|
+
});
|
|
19815
|
+
};
|
|
19816
|
+
/**
|
|
19817
|
+
* Transforms locale to a locale that is supported by the browser
|
|
19818
|
+
* @param locale Two-letter locale code to transform (en, fr, etc.)
|
|
19819
|
+
* @returns Full locale string (e.g., en-GB, fr-FR)
|
|
19820
|
+
*/
|
|
19821
|
+
var transformLocale = function (locale) {
|
|
19822
|
+
var localeMapping = {
|
|
19823
|
+
en: 'en-GB',
|
|
19824
|
+
fr: 'fr-FR',
|
|
19825
|
+
es: 'es-ES',
|
|
19826
|
+
de: 'de-DE',
|
|
19827
|
+
it: 'it-IT',
|
|
19828
|
+
pt: 'pt-PT',
|
|
19829
|
+
us: 'en-US'
|
|
19830
|
+
};
|
|
19831
|
+
var languageCode = (locale !== null && locale !== void 0 ? locale : 'en').toLowerCase();
|
|
19832
|
+
return localeMapping[languageCode] || 'en-GB';
|
|
19833
|
+
};
|
|
19834
|
+
/**
|
|
19835
|
+
* Formats a date string to a localized date string based on user locale
|
|
19836
|
+
* @param date Date string to format
|
|
19837
|
+
* @param userLocale User's locale (defaults to 'en')
|
|
19838
|
+
* @returns Formatted date string or fallback message
|
|
19839
|
+
*/
|
|
19840
|
+
var handleLastEarnedDate = function (date, userLocale) {
|
|
19841
|
+
if (userLocale === void 0) {
|
|
19842
|
+
userLocale = 'en';
|
|
19843
|
+
}
|
|
19844
|
+
if (!date) return 'Date not available';
|
|
19845
|
+
try {
|
|
19846
|
+
var formattedLocale = transformLocale(userLocale);
|
|
19847
|
+
var dateObj = new Date(date);
|
|
19848
|
+
if (isNaN(dateObj.getTime())) {
|
|
19849
|
+
return 'Invalid Date';
|
|
19850
|
+
}
|
|
19851
|
+
return dateObj.toLocaleDateString(formattedLocale);
|
|
19852
|
+
} catch (error) {
|
|
19853
|
+
console.error('Error formatting date:', error);
|
|
19854
|
+
return 'Invalid Date';
|
|
19855
|
+
}
|
|
19856
|
+
};
|
|
19857
|
+
|
|
19801
19858
|
/**
|
|
19802
19859
|
* Custom hook that returns the styles for the BadgeTile component.
|
|
19803
19860
|
* Applies responsive styling based on the current device.
|
|
@@ -19865,9 +19922,10 @@ var BadgeTileDateEarned = function () {
|
|
|
19865
19922
|
var _a = tileContext.configuration,
|
|
19866
19923
|
count = _a.count,
|
|
19867
19924
|
awardedDatePrefix = _a.awardedDatePrefix,
|
|
19868
|
-
|
|
19925
|
+
lastEarnedAt = _a.lastEarnedAt,
|
|
19869
19926
|
badgeNotEarnedMessage = _a.badgeNotEarnedMessage,
|
|
19870
|
-
type = _a.type
|
|
19927
|
+
type = _a.type,
|
|
19928
|
+
locale = _a.locale;
|
|
19871
19929
|
// Don't show for Latest type with count=0
|
|
19872
19930
|
if (type === exports.BadgeTileType.Latest && count === 0) {
|
|
19873
19931
|
return null;
|
|
@@ -19881,8 +19939,8 @@ var BadgeTileDateEarned = function () {
|
|
|
19881
19939
|
backgroundColor: backgroundColor
|
|
19882
19940
|
}];
|
|
19883
19941
|
var textColor = getReadableTextColor(backgroundColor);
|
|
19884
|
-
var displayText = count === 0 ? badgeNotEarnedMessage : "".concat(awardedDatePrefix, " ").concat(
|
|
19885
|
-
var accessibilityLabel = count === 0 ? 'Badge not yet earned' : "Badge earned on ".concat(
|
|
19942
|
+
var displayText = count === 0 ? badgeNotEarnedMessage : "".concat(awardedDatePrefix, " ").concat(handleLastEarnedDate(lastEarnedAt, locale));
|
|
19943
|
+
var accessibilityLabel = count === 0 ? 'Badge not yet earned' : "Badge earned on ".concat(handleLastEarnedDate(lastEarnedAt, locale));
|
|
19886
19944
|
return /*#__PURE__*/React.createElement(View$2, {
|
|
19887
19945
|
style: containerStyle,
|
|
19888
19946
|
accessible: true,
|
|
@@ -20136,7 +20194,7 @@ var BannerTileDescription = function () {
|
|
|
20136
20194
|
if (!description) return null;
|
|
20137
20195
|
return /*#__PURE__*/React.createElement(Text, {
|
|
20138
20196
|
style: styles.description,
|
|
20139
|
-
|
|
20197
|
+
role: "article",
|
|
20140
20198
|
accessibilityLabel: description,
|
|
20141
20199
|
testID: "banner-tile-description"
|
|
20142
20200
|
}, description);
|
|
@@ -20161,7 +20219,7 @@ var BannerTileMedia = function (_a) {
|
|
|
20161
20219
|
};
|
|
20162
20220
|
return /*#__PURE__*/React.createElement(View$2, {
|
|
20163
20221
|
style: [styles.mediaContainer, containerStyle],
|
|
20164
|
-
|
|
20222
|
+
role: "img",
|
|
20165
20223
|
accessibilityLabel: "Banner image".concat(title ? " for ".concat(title) : ''),
|
|
20166
20224
|
testID: "banner-tile-media"
|
|
20167
20225
|
}, /*#__PURE__*/React.createElement(ProgressiveImage, {
|
|
@@ -20188,7 +20246,7 @@ var BannerTileTitle = function () {
|
|
|
20188
20246
|
variant: "title",
|
|
20189
20247
|
testID: "banner-tile-title",
|
|
20190
20248
|
style: styles.title,
|
|
20191
|
-
|
|
20249
|
+
role: "heading",
|
|
20192
20250
|
accessibilityLabel: title
|
|
20193
20251
|
}, title);
|
|
20194
20252
|
};
|
|
@@ -20315,7 +20373,7 @@ var ContentTileMedia = function (_a) {
|
|
|
20315
20373
|
return /*#__PURE__*/React.createElement(View$2, {
|
|
20316
20374
|
style: [styles.imageContainer, containerStyle],
|
|
20317
20375
|
testID: "content-tile-media",
|
|
20318
|
-
|
|
20376
|
+
role: "img",
|
|
20319
20377
|
accessibilityLabel: "Image for ".concat(title)
|
|
20320
20378
|
}, /*#__PURE__*/React.createElement(ProgressiveImage, {
|
|
20321
20379
|
source: {
|
|
@@ -20340,7 +20398,7 @@ var ContentTileSummary = function () {
|
|
|
20340
20398
|
};
|
|
20341
20399
|
return /*#__PURE__*/React.createElement(Text, {
|
|
20342
20400
|
variant: "body",
|
|
20343
|
-
|
|
20401
|
+
role: "article",
|
|
20344
20402
|
accessibilityLabel: body,
|
|
20345
20403
|
numberOfLines: getNumberOfLines(),
|
|
20346
20404
|
testID: "content-tile-summary"
|
|
@@ -20362,7 +20420,7 @@ var ContentTileTitle = function () {
|
|
|
20362
20420
|
};
|
|
20363
20421
|
return /*#__PURE__*/React.createElement(Text, {
|
|
20364
20422
|
variant: "title",
|
|
20365
|
-
|
|
20423
|
+
role: "heading",
|
|
20366
20424
|
accessibilityLabel: title,
|
|
20367
20425
|
numberOfLines: 1,
|
|
20368
20426
|
style: handleTitleWidth(),
|
|
@@ -20421,22 +20479,6 @@ var ContentTile = Object.assign(ContentTileRoot, {
|
|
|
20421
20479
|
});
|
|
20422
20480
|
var ContentTile$1 = withTileFetching(ContentTile);
|
|
20423
20481
|
|
|
20424
|
-
/**
|
|
20425
|
-
* Sorts tiles by priority (higher priority first) and maintains original order for equal priorities
|
|
20426
|
-
* @param tiles Array of tiles to sort
|
|
20427
|
-
* @returns Sorted array of tiles
|
|
20428
|
-
*/
|
|
20429
|
-
var sortByPriority = function (tiles) {
|
|
20430
|
-
return __spreadArray([], tiles, true).sort(function (a, b) {
|
|
20431
|
-
// Sort by priority (higher priority first)
|
|
20432
|
-
if (a.priority !== b.priority) {
|
|
20433
|
-
return b.priority - a.priority;
|
|
20434
|
-
}
|
|
20435
|
-
// If priorities are equal, maintain original order
|
|
20436
|
-
return tiles.indexOf(a) - tiles.indexOf(b);
|
|
20437
|
-
});
|
|
20438
|
-
};
|
|
20439
|
-
|
|
20440
20482
|
exports.SectionType = void 0;
|
|
20441
20483
|
(function (SectionType) {
|
|
20442
20484
|
SectionType["Grid"] = "GRID";
|
|
@@ -21075,7 +21117,7 @@ var EmptyState = function (_a) {
|
|
|
21075
21117
|
var message = _a.message;
|
|
21076
21118
|
return /*#__PURE__*/React.createElement(View$2, {
|
|
21077
21119
|
style: commonStyles.emptyContainer,
|
|
21078
|
-
|
|
21120
|
+
role: "article",
|
|
21079
21121
|
accessibilityLabel: "Empty state: ".concat(message)
|
|
21080
21122
|
}, /*#__PURE__*/React.createElement(Text$3, null, message));
|
|
21081
21123
|
};
|
|
@@ -21664,7 +21706,7 @@ var PointsTileFormattedPoints = function () {
|
|
|
21664
21706
|
var fullPointsText = "".concat(pointsPrefix).concat(calculatedPoints, " ").concat(pointsSuffix).trim();
|
|
21665
21707
|
return /*#__PURE__*/React.createElement(View$2, {
|
|
21666
21708
|
testID: "points-tile-points",
|
|
21667
|
-
|
|
21709
|
+
role: "article",
|
|
21668
21710
|
accessibilityLabel: "Points value: ".concat(fullPointsText)
|
|
21669
21711
|
}, /*#__PURE__*/React.createElement(Row, {
|
|
21670
21712
|
align: "center",
|
|
@@ -21700,7 +21742,7 @@ var PointsTileMedia = function (_a) {
|
|
|
21700
21742
|
return /*#__PURE__*/React.createElement(View$2, {
|
|
21701
21743
|
testID: "points-tile-media",
|
|
21702
21744
|
style: styles.imageContainer,
|
|
21703
|
-
|
|
21745
|
+
role: "img",
|
|
21704
21746
|
accessibilityLabel: "Points tile image for ".concat(title)
|
|
21705
21747
|
}, /*#__PURE__*/React.createElement(Image$2, {
|
|
21706
21748
|
source: {
|
|
@@ -21724,7 +21766,7 @@ var PointsTileTitle = function () {
|
|
|
21724
21766
|
return /*#__PURE__*/React.createElement(Text, {
|
|
21725
21767
|
variant: "eyebrow",
|
|
21726
21768
|
testID: "points-tile-title",
|
|
21727
|
-
|
|
21769
|
+
role: "heading",
|
|
21728
21770
|
accessibilityLabel: title
|
|
21729
21771
|
}, title);
|
|
21730
21772
|
};
|
|
@@ -21822,7 +21864,7 @@ var RewardCategoryHeader = function () {
|
|
|
21822
21864
|
backgroundColor: theme.primary
|
|
21823
21865
|
}],
|
|
21824
21866
|
testID: "reward-category-header",
|
|
21825
|
-
|
|
21867
|
+
role: "heading",
|
|
21826
21868
|
accessibilityLabel: "Reward category: ".concat(name)
|
|
21827
21869
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
21828
21870
|
style: [styles.headerText, {
|
|
@@ -21854,7 +21896,7 @@ var RewardCategoryMedia = function () {
|
|
|
21854
21896
|
},
|
|
21855
21897
|
style: styles.background,
|
|
21856
21898
|
alt: "Reward category image for ".concat(name),
|
|
21857
|
-
|
|
21899
|
+
role: "img"
|
|
21858
21900
|
});
|
|
21859
21901
|
};
|
|
21860
21902
|
|
|
@@ -21893,7 +21935,7 @@ var RewardTileChevron = function () {
|
|
|
21893
21935
|
name: "ChevronRight",
|
|
21894
21936
|
size: IS_MOBILE ? 16 : undefined,
|
|
21895
21937
|
color: ((_a = theme === null || theme === void 0 ? void 0 : theme.derivedSurfaceText) === null || _a === void 0 ? void 0 : _a[20]) || '#000000',
|
|
21896
|
-
|
|
21938
|
+
role: "img",
|
|
21897
21939
|
accessibilityLabel: "View reward details"
|
|
21898
21940
|
});
|
|
21899
21941
|
};
|
|
@@ -21977,7 +22019,7 @@ var RewardTileMedia = function (_a) {
|
|
|
21977
22019
|
return /*#__PURE__*/React.createElement(View$2, {
|
|
21978
22020
|
style: [styles.imageContainer, containerStyle],
|
|
21979
22021
|
testID: "reward-tile-media",
|
|
21980
|
-
|
|
22022
|
+
role: "img",
|
|
21981
22023
|
accessibilityLabel: "Reward image for ".concat(name)
|
|
21982
22024
|
}, /*#__PURE__*/React.createElement(ProgressiveImage, {
|
|
21983
22025
|
source: {
|
|
@@ -22013,7 +22055,7 @@ var RewardTilePoints = function () {
|
|
|
22013
22055
|
var accessibilityLabel = getPointsLabel('Reward points:', calculatedPoints, pointsPrefix, pointsSuffix);
|
|
22014
22056
|
return /*#__PURE__*/React.createElement(View$2, {
|
|
22015
22057
|
testID: "reward-tile-points",
|
|
22016
|
-
|
|
22058
|
+
role: "article",
|
|
22017
22059
|
accessibilityLabel: accessibilityLabel
|
|
22018
22060
|
}, /*#__PURE__*/React.createElement(Row, {
|
|
22019
22061
|
align: "center",
|
|
@@ -22044,7 +22086,7 @@ var RewardTileSummary = function () {
|
|
|
22044
22086
|
if (!summary) return null;
|
|
22045
22087
|
return /*#__PURE__*/React.createElement(Text, {
|
|
22046
22088
|
variant: "body",
|
|
22047
|
-
|
|
22089
|
+
role: "article",
|
|
22048
22090
|
accessibilityLabel: summary,
|
|
22049
22091
|
testID: "reward-tile-summary"
|
|
22050
22092
|
}, summary);
|
|
@@ -22070,7 +22112,7 @@ var RewardTileTitle = function () {
|
|
|
22070
22112
|
variant: "title",
|
|
22071
22113
|
ellipsizeMode: "tail",
|
|
22072
22114
|
numberOfLines: 1,
|
|
22073
|
-
|
|
22115
|
+
role: "heading",
|
|
22074
22116
|
accessibilityLabel: "Reward title: ".concat(name),
|
|
22075
22117
|
testID: "reward-tile-title",
|
|
22076
22118
|
style: handleTitleWidth()
|