@wlloyalty/wll-react-sdk 1.2.1 → 1.3.1

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
@@ -691,6 +691,7 @@ type SDKConfig = {
691
691
  userToken?: string;
692
692
  fetcher?: Fetcher;
693
693
  locale?: string;
694
+ environment?: 'PRODUCTION' | 'STAGING' | 'DEVELOPMENT';
694
695
  };
695
696
  type APIResponse<T> = {
696
697
  status: 'success' | 'error';
package/dist/native.js CHANGED
@@ -1523,7 +1523,18 @@ var useNavigation = function (config) {
1523
1523
  return handleNavigation;
1524
1524
  };
1525
1525
 
1526
- var baseUrl = 'https://api.staging.core.wlloyalty.net/v1';
1526
+ var getBaseUrl = function (environment) {
1527
+ if (environment === void 0) { environment = 'STAGING'; }
1528
+ switch (environment) {
1529
+ case 'PRODUCTION':
1530
+ return 'https://api.core.wlloyalty.net/v1';
1531
+ case 'DEVELOPMENT':
1532
+ return 'https://localhost:8080/v1';
1533
+ case 'STAGING':
1534
+ default:
1535
+ return 'https://api.staging.core.wlloyalty.net/v1';
1536
+ }
1537
+ };
1527
1538
  var useCreateRequestOptions = function (config) {
1528
1539
  return React.useCallback(function (options) {
1529
1540
  if (options === void 0) { options = {}; }
@@ -1586,9 +1597,11 @@ var createResourceGetter = function (resource, includeHydrate) {
1586
1597
  }
1587
1598
  // Always append locale=en
1588
1599
  params.append('locale', config.locale || 'en');
1600
+ var env = config.environment || 'STAGING';
1601
+ var baseUrl = getBaseUrl(env);
1589
1602
  var queryString = params.toString();
1590
1603
  return makeRequest("".concat(baseUrl, "/tiles-management/").concat(resource, "/").concat(id).concat(queryString ? "?".concat(queryString) : ''));
1591
- }, [makeRequest]);
1604
+ }, [makeRequest, config.environment]);
1592
1605
  };
1593
1606
  };
1594
1607
  var useGetGroupByID = createResourceGetter('groups', true);
@@ -1917,8 +1930,8 @@ var DIMENSION_MODES = {
1917
1930
  TABLET: 'tablet',
1918
1931
  MOBILE: 'mobile',
1919
1932
  };
1920
- var TABLET_SCREEN_WIDTH = 728;
1921
- var SMALL_SCREEN_WIDTH = 530;
1933
+ var TABLET_SCREEN_WIDTH = 768;
1934
+ var SMALL_SCREEN_WIDTH = 480;
1922
1935
 
1923
1936
  var isWeb = reactNative.Platform.OS === 'web';
1924
1937
  function getDimensionMode(window) {
@@ -2090,6 +2103,9 @@ var validateConfig = function (config) {
2090
2103
  if (config.locale && !/^[a-z]{2}$/.test(config.locale)) {
2091
2104
  throw new Error('Invalid locale format. Expected ISO 639-1 language code (e.g. "en")');
2092
2105
  }
2106
+ if (!config.environment) {
2107
+ config.environment = 'STAGING';
2108
+ }
2093
2109
  };
2094
2110
 
2095
2111
  function createVariantSystem(baseStyle, variantStyles) {
@@ -2387,7 +2403,7 @@ var Text = function (_a) {
2387
2403
  case 'eyebrow':
2388
2404
  return __assign(__assign({}, baseStyle), { fontSize: useResponsiveValue(theme.sizes.md, theme.sizes.sm, isDesktop, isTablet), marginBottom: useResponsiveValue(theme.sizes.xxs, theme.sizes.xxxs, isDesktop, isTablet) });
2389
2405
  case 'title':
2390
- return __assign(__assign({}, baseStyle), { fontSize: useResponsiveValue(theme.sizes.xxl, theme.sizes.md, isDesktop, isTablet), fontWeight: 'bold' });
2406
+ return __assign(__assign({}, baseStyle), { fontSize: useResponsiveValue(theme.sizes.xl, theme.sizes.md, isDesktop, isTablet), fontWeight: 'bold' });
2391
2407
  case 'body':
2392
2408
  return {
2393
2409
  color: theme.derivedSurfaceText[20],
@@ -2398,7 +2414,7 @@ var Text = function (_a) {
2398
2414
  case 'description':
2399
2415
  case 'label':
2400
2416
  default:
2401
- return __assign(__assign({}, baseStyle), { fontSize: useResponsiveValue(theme.sizes.sm, theme.sizes.xs, isDesktop, isTablet) });
2417
+ return __assign(__assign({}, baseStyle), { fontSize: useResponsiveValue(theme.sizes.sm, theme.sizes.xxs, isDesktop, isTablet) });
2402
2418
  }
2403
2419
  };
2404
2420
  var variantStyle = getVariantStyle(variant);
@@ -3323,6 +3339,7 @@ var BadgeTileDateEarned = function () {
3323
3339
  */
3324
3340
  var BadgeTileDescription = function () {
3325
3341
  var tileContext = useTileContext();
3342
+ var width = reactNative.useWindowDimensions().width;
3326
3343
  if (!isContextValid(tileContext))
3327
3344
  return null;
3328
3345
  var _a = tileContext.configuration, count = _a.count, description = _a.description, type = _a.type;
@@ -3332,7 +3349,19 @@ var BadgeTileDescription = function () {
3332
3349
  // For Specific type, always show description
3333
3350
  if (count === 0 && type === exports.BadgeTileType.Latest)
3334
3351
  return null;
3335
- return (jsxRuntimeExports.jsx(reactNative.View, { accessible: true, accessibilityLabel: "Badge description: ".concat(description), testID: "badge-tile-description", children: jsxRuntimeExports.jsx(Text, { variant: "body", numberOfLines: 2, ellipsizeMode: "tail", accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: description }) }));
3352
+ var numberOfLines = React.useMemo(function () {
3353
+ if (width <= 480)
3354
+ return 2;
3355
+ if (width <= 768)
3356
+ return 3;
3357
+ if (width <= 1024)
3358
+ return 1;
3359
+ return 2;
3360
+ }, [width]);
3361
+ return (jsxRuntimeExports.jsx(reactNative.View, { accessible: true, accessibilityLabel: "Badge description: ".concat(description), testID: "badge-tile-description", style: {
3362
+ width: '100%',
3363
+ overflow: 'hidden',
3364
+ }, children: jsxRuntimeExports.jsx(Text, { variant: "body", numberOfLines: numberOfLines, ellipsizeMode: "tail", accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: description }) }));
3336
3365
  };
3337
3366
 
3338
3367
  /**
@@ -3394,7 +3423,7 @@ var BadgeTileTitle = function () {
3394
3423
  : name;
3395
3424
  if (!displayText)
3396
3425
  return null;
3397
- return (jsxRuntimeExports.jsx(reactNative.View, { accessible: true, accessibilityLabel: "Badge title: ".concat(displayText), testID: "badge-tile-title", children: jsxRuntimeExports.jsx(Text, { variant: "title", style: styles.titleText, numberOfLines: count === 0 ? 2 : 1, ellipsizeMode: "tail", accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: displayText }) }));
3426
+ return (jsxRuntimeExports.jsx(reactNative.View, { accessible: true, accessibilityLabel: "Badge title: ".concat(displayText), testID: "badge-tile-title", children: jsxRuntimeExports.jsx(Text, { variant: "title", style: styles.titleText, numberOfLines: 1, ellipsizeMode: "tail", accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: displayText }) }));
3398
3427
  };
3399
3428
 
3400
3429
  /**
@@ -3631,27 +3660,58 @@ var ContentTileMedia = function (_a) {
3631
3660
 
3632
3661
  var ContentTileSummary = function () {
3633
3662
  var tileContext = useTileContext();
3663
+ var sizeInfo = useTileSize(tileContext);
3634
3664
  if (!isContextValid(tileContext))
3635
3665
  return null;
3636
- var body = tileContext.configuration.body;
3666
+ var _a = tileContext.configuration, body = _a.body, title = _a.title, artworkUrl = _a.artworkUrl;
3637
3667
  if (!body)
3638
3668
  return null;
3639
- var sizeInfo = useTileSize(tileContext);
3640
3669
  if (!sizeInfo)
3641
3670
  return null;
3642
- var isFullSize = sizeInfo.isFullSize, isHalfSize = sizeInfo.isHalfSize;
3643
- var getNumberOfLines = function () {
3644
- return isFullSize ? 3 : isHalfSize ? 4 : 3;
3645
- };
3646
- return (jsxRuntimeExports.jsx(Text, { variant: "body", role: "article", accessibilityLabel: body, numberOfLines: getNumberOfLines(), testID: "content-tile-summary", children: body }));
3671
+ var isHalfSize = sizeInfo.isHalfSize;
3672
+ var numberOfLines = React.useMemo(function () {
3673
+ if (!body)
3674
+ return undefined;
3675
+ if (isHalfSize) {
3676
+ if (!title && body)
3677
+ return 4;
3678
+ if (title && body)
3679
+ return 2;
3680
+ }
3681
+ if (artworkUrl)
3682
+ return 3;
3683
+ if (!title)
3684
+ return 8;
3685
+ return 6;
3686
+ }, [title, body, artworkUrl, isHalfSize]);
3687
+ return (jsxRuntimeExports.jsx(Text, { variant: "body", role: "article", accessibilityLabel: body, numberOfLines: numberOfLines, testID: "content-tile-summary", children: body }));
3647
3688
  };
3648
3689
 
3649
3690
  var ContentTileTitle = function () {
3650
3691
  var tileContext = useTileContext();
3651
3692
  var styles = useContentTileStyles();
3693
+ var sizeInfo = useTileSize(tileContext);
3652
3694
  if (!isContextValid(tileContext))
3653
3695
  return null;
3654
- var _a = tileContext.configuration, title = _a.title, ctaLink = _a.ctaLink;
3696
+ var _a = tileContext.configuration, title = _a.title, ctaLink = _a.ctaLink, body = _a.body, artworkUrl = _a.artworkUrl;
3697
+ if (!sizeInfo)
3698
+ return null;
3699
+ var isHalfSize = sizeInfo.isHalfSize;
3700
+ var numberOfLines = React.useMemo(function () {
3701
+ if (!title)
3702
+ return undefined;
3703
+ if (isHalfSize) {
3704
+ if (title && !body)
3705
+ return 3;
3706
+ if (title && body)
3707
+ return 1;
3708
+ }
3709
+ if (artworkUrl)
3710
+ return 1;
3711
+ if (!body)
3712
+ return 7;
3713
+ return 2;
3714
+ }, [title, body, artworkUrl, isHalfSize]);
3655
3715
  if (!title)
3656
3716
  return null;
3657
3717
  var handleTitleWidth = function () {
@@ -3659,7 +3719,7 @@ var ContentTileTitle = function () {
3659
3719
  return styles.titleWithLink;
3660
3720
  }
3661
3721
  };
3662
- return (jsxRuntimeExports.jsx(Text, { variant: "title", role: "heading", accessibilityLabel: title, numberOfLines: 1, style: handleTitleWidth(), testID: "content-tile-title", children: title }));
3722
+ return (jsxRuntimeExports.jsx(Text, { variant: "title", role: "heading", accessibilityLabel: title, numberOfLines: numberOfLines, style: handleTitleWidth(), testID: "content-tile-title", children: title }));
3663
3723
  };
3664
3724
 
3665
3725
  /**
@@ -3821,14 +3881,14 @@ var useSectionHeaderStyles = function () {
3821
3881
  marginBottom: useResponsiveValue(theme.sizes.lg, theme.sizes.xxs, isDesktop, isTablet),
3822
3882
  },
3823
3883
  sectionTitle: {
3824
- fontSize: useResponsiveValue(theme.sizes.xxxl, theme.sizes.xl, isDesktop, isTablet),
3884
+ fontSize: useResponsiveValue(theme.sizes.xxl, theme.sizes.xl, isDesktop, isTablet),
3825
3885
  marginBottom: useResponsiveValue(theme.sizes.xxs, theme.sizes.xxxs, isDesktop, isTablet),
3826
3886
  fontWeight: '700',
3827
3887
  color: theme.text,
3828
3888
  fontFamily: theme.fontFamily,
3829
3889
  },
3830
3890
  sectionDescription: {
3831
- fontSize: useResponsiveValue(theme.sizes.xxl, theme.sizes.md, isDesktop, isTablet),
3891
+ fontSize: useResponsiveValue(theme.sizes.xl, theme.sizes.md, isDesktop, isTablet),
3832
3892
  color: theme.alphaDerivedText[80],
3833
3893
  fontFamily: theme.fontFamily,
3834
3894
  },
@@ -4934,10 +4994,12 @@ var RewardTileSummary = function () {
4934
4994
  var tileContext = useTileContext();
4935
4995
  if (!isContextValid(tileContext))
4936
4996
  return null;
4937
- var summary = tileContext.configuration.summary;
4997
+ var _a = tileContext.configuration, summary = _a.summary, _b = _a.showPrice, showPrice = _b === void 0 ? true : _b, price = _a.price;
4998
+ var shouldShowPrice = showPrice && price !== undefined && price !== null && price !== 0;
4999
+ var numberOfLines = shouldShowPrice ? 1 : 3;
4938
5000
  if (!summary)
4939
5001
  return null;
4940
- return (jsxRuntimeExports.jsx(Text, { variant: "body", role: "article", accessibilityLabel: summary, testID: "reward-tile-summary", children: summary }));
5002
+ return (jsxRuntimeExports.jsx(Text, { variant: "body", role: "article", accessibilityLabel: summary, testID: "reward-tile-summary", numberOfLines: numberOfLines, ellipsizeMode: "tail", children: summary }));
4941
5003
  };
4942
5004
 
4943
5005
  /**