@wlloyalty/wll-react-sdk 1.0.112 → 1.1.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.
@@ -1,4 +1,4 @@
1
- import { TGroup } from '../types/group';
1
+ import type { TGroup } from '../types/group';
2
2
  type UseInitialGroupFetchProps = {
3
3
  id: string;
4
4
  setGroupData: (group: TGroup) => void;
@@ -2,6 +2,10 @@ import { CTALinkTarget, RoundupTileConfig, TileHeight, TileType } from '../../ty
2
2
  export type RoundupTileMockConfig = Partial<RoundupTileConfig> & {
3
3
  active?: boolean;
4
4
  tileHeight?: TileHeight;
5
+ defaultLocale?: string;
6
+ details?: any[];
7
+ locale?: string;
8
+ balance?: number;
5
9
  };
6
10
  export declare const createRoundupTileMock: (config?: RoundupTileMockConfig) => {
7
11
  id: string;
@@ -13,11 +17,14 @@ export declare const createRoundupTileMock: (config?: RoundupTileMockConfig) =>
13
17
  priority: number;
14
18
  configuration: {
15
19
  title: string | null;
16
- amount: number;
17
- amountPrefix: string | null;
18
- amountSuffix: string | null;
19
20
  artworkUrl: string | null;
20
21
  ctaLink: string | null | undefined;
21
22
  ctaLinkTarget: CTALinkTarget | undefined;
23
+ defaultLocale: string;
24
+ details: any[];
25
+ locale: string;
26
+ balance: number | undefined;
27
+ amountPrefix: string | null | undefined;
28
+ amountSuffix: string | null | undefined;
22
29
  };
23
30
  };
@@ -49,7 +49,7 @@ export declare class RoundupTileConfig {
49
49
  amountPrefix?: string | null;
50
50
  amountSuffix?: string | null;
51
51
  artworkUrl?: string | null;
52
- amount?: number;
52
+ balance?: number;
53
53
  ctaLink?: string | null;
54
54
  ctaLinkTarget?: CTALinkTarget;
55
55
  }
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Cleans up a number by removing any whitespace and ensuring it's a valid number
3
+ * @param value The number to clean up
4
+ * @returns A cleaned up number as a number
5
+ */
6
+ export declare const cleanNumber: (value: number) => number;
1
7
  /**
2
8
  * Applies a multiplier to a base value. Handles string multipliers by converting them to numbers.
3
9
  * If the multiplier is invalid (NaN, null, undefined), defaults to 1.
package/dist/web.js CHANGED
@@ -20650,50 +20650,41 @@ var useInitialGroupFetch = function (_a) {
20650
20650
  var _c = React.useState(null),
20651
20651
  error = _c[0],
20652
20652
  setError = _c[1];
20653
- var fetchInProgressRef = React.useRef(false);
20654
20653
  React.useEffect(function () {
20655
- var isMounted = true;
20656
- var fetch = function () {
20654
+ var cancelled = false;
20655
+ var fetchGroup = function () {
20657
20656
  return __awaiter(void 0, void 0, void 0, function () {
20658
20657
  var response;
20659
- var _a;
20660
- return __generator(this, function (_b) {
20661
- switch (_b.label) {
20658
+ var _b;
20659
+ return __generator(this, function (_c) {
20660
+ switch (_c.label) {
20662
20661
  case 0:
20663
- if (fetchInProgressRef.current) {
20664
- return [2 /*return*/];
20665
- }
20666
- fetchInProgressRef.current = true;
20667
- if (!id || !sdk || !sdk.refreshGroup) {
20662
+ if (!id || !(sdk === null || sdk === void 0 ? void 0 : sdk.refreshGroup)) {
20668
20663
  setError('Unable to fetch group data: invalid configuration');
20669
20664
  setIsLoading(false);
20670
20665
  return [2 /*return*/];
20671
20666
  }
20672
20667
  setIsLoading(true);
20673
20668
  setError(null);
20674
- _b.label = 1;
20669
+ _c.label = 1;
20675
20670
  case 1:
20676
- _b.trys.push([1, 3, 4, 5]);
20671
+ _c.trys.push([1, 3, 4, 5]);
20677
20672
  return [4 /*yield*/, sdk.refreshGroup(id)];
20678
20673
  case 2:
20679
- response = _b.sent();
20680
- if (!isMounted) return [2 /*return*/];
20674
+ response = _c.sent();
20675
+ if (cancelled) return [2 /*return*/];
20681
20676
  if ((response === null || response === void 0 ? void 0 : response.status) === 'success' && response.data) {
20682
20677
  setGroupData(response.data);
20683
20678
  } else {
20684
- setError((_a = response === null || response === void 0 ? void 0 : response.error) !== null && _a !== void 0 ? _a : 'Failed to fetch group data');
20679
+ setError((_b = response === null || response === void 0 ? void 0 : response.error) !== null && _b !== void 0 ? _b : 'Failed to fetch group data');
20685
20680
  }
20686
20681
  return [3 /*break*/, 5];
20687
20682
  case 3:
20688
- _b.sent();
20689
- if (isMounted) {
20690
- setError('An unexpected error occurred.');
20691
- }
20683
+ _c.sent();
20684
+ if (!cancelled) setError('An unexpected error occurred.');
20692
20685
  return [3 /*break*/, 5];
20693
20686
  case 4:
20694
- if (isMounted) {
20695
- setIsLoading(false);
20696
- }
20687
+ if (!cancelled) setIsLoading(false);
20697
20688
  return [7 /*endfinally*/];
20698
20689
  case 5:
20699
20690
  return [2 /*return*/];
@@ -20701,9 +20692,9 @@ var useInitialGroupFetch = function (_a) {
20701
20692
  });
20702
20693
  });
20703
20694
  };
20704
- fetch();
20695
+ fetchGroup();
20705
20696
  return function () {
20706
- isMounted = false;
20697
+ cancelled = true;
20707
20698
  };
20708
20699
  }, [id, sdk, setGroupData]);
20709
20700
  return {
@@ -21528,7 +21519,7 @@ var Group = function (_a) {
21528
21519
  return /*#__PURE__*/React.createElement(View$2, {
21529
21520
  style: {
21530
21521
  flex: 1,
21531
- padding: theme.sizes.lg
21522
+ padding: IS_MOBILE ? theme.sizes.lg : undefined
21532
21523
  },
21533
21524
  accessible: true,
21534
21525
  accessibilityLabel: "Loading group data"
@@ -22514,6 +22505,36 @@ TierTile.Full = TierTileFull;
22514
22505
  TierTile.Half = TierTileHalf;
22515
22506
  TierTile.Empty = TierTileEmpty;
22516
22507
 
22508
+ /**
22509
+ * Renders formatted points value for a Roundup Tile.
22510
+ *
22511
+ * @returns JSX.Element or null if points are undefined or zero
22512
+ */
22513
+ var RoundupTileFormattedPoints = function () {
22514
+ var tileContext = useTileContext();
22515
+ if (!isContextValid(tileContext)) return null;
22516
+ var _a = tileContext.configuration,
22517
+ _b = _a.balance,
22518
+ balance = _b === void 0 ? 0 : _b,
22519
+ _c = _a.amountPrefix,
22520
+ amountPrefix = _c === void 0 ? '' : _c,
22521
+ _d = _a.amountSuffix,
22522
+ amountSuffix = _d === void 0 ? '' : _d;
22523
+ if (balance === undefined) return null;
22524
+ var fullPointsText = "".concat(amountPrefix).concat(cleanNumber(balance)).concat(amountSuffix).trim();
22525
+ return /*#__PURE__*/React.createElement(View$2, {
22526
+ testID: "roundup-tile-amount",
22527
+ role: "article",
22528
+ accessibilityLabel: "Amount: ".concat(fullPointsText)
22529
+ }, /*#__PURE__*/React.createElement(Row, {
22530
+ align: "center",
22531
+ justify: "start"
22532
+ }, /*#__PURE__*/React.createElement(Text, {
22533
+ variant: "caption",
22534
+ testID: "roundup-tile-value"
22535
+ }, fullPointsText)));
22536
+ };
22537
+
22517
22538
  /**
22518
22539
  * Custom hook that returns the styles for the RoundupTile component.
22519
22540
  * Applies responsive styling based on the current device.
@@ -22534,8 +22555,7 @@ var useRoundupTileStyles = function (isFullSize) {
22534
22555
  justifyContent: 'space-between'
22535
22556
  },
22536
22557
  contentContainer: {
22537
- width: '100%',
22538
- marginTop: isFullSize ? useResponsiveValue(theme.sizes.xxl, theme.sizes.md, isDesktop, isTablet) : 0
22558
+ width: '100%'
22539
22559
  },
22540
22560
  contentColumn: {
22541
22561
  flexGrow: 1
@@ -22574,44 +22594,6 @@ var useRoundupTileStyles = function (isFullSize) {
22574
22594
  });
22575
22595
  };
22576
22596
 
22577
- /**
22578
- * Renders formatted points value for a Roundup Tile.
22579
- *
22580
- * @returns JSX.Element or null if points are undefined or zero
22581
- */
22582
- var RoundupTileFormattedPoints = function () {
22583
- var styles = useRoundupTileStyles();
22584
- var tileContext = useTileContext();
22585
- if (!isContextValid(tileContext)) return null;
22586
- var _a = tileContext.configuration,
22587
- _b = _a.amountPrefix,
22588
- amountPrefix = _b === void 0 ? '' : _b,
22589
- _c = _a.amountSuffix,
22590
- amountSuffix = _c === void 0 ? '' : _c,
22591
- _d = _a.amount,
22592
- amount = _d === void 0 ? 0 : _d;
22593
- if (amount === undefined) return null;
22594
- var fullPointsText = "".concat(amountPrefix).concat(amount, " ").concat(amountSuffix).trim();
22595
- return /*#__PURE__*/React.createElement(View$2, {
22596
- testID: "roundup-tile-amount",
22597
- role: "article",
22598
- accessibilityLabel: "Amount: ".concat(fullPointsText)
22599
- }, /*#__PURE__*/React.createElement(Row, {
22600
- align: "center",
22601
- justify: "start"
22602
- }, amountPrefix ? (/*#__PURE__*/React.createElement(Text, {
22603
- variant: "caption",
22604
- testID: "roundup-tile-prefix"
22605
- }, amountPrefix)) : null, /*#__PURE__*/React.createElement(Text, {
22606
- variant: "caption",
22607
- testID: "roundup-tile-value"
22608
- }, amount), amountSuffix ? (/*#__PURE__*/React.createElement(Text, {
22609
- variant: "caption",
22610
- style: styles.suffix,
22611
- testID: "roundup-tile-suffix"
22612
- }, amountSuffix)) : null));
22613
- };
22614
-
22615
22597
  /**
22616
22598
  * Renders the media of a Points Tile.
22617
22599
  *