@wlloyalty/wll-react-sdk 1.4.5 → 1.4.6

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
@@ -2,7 +2,7 @@ import * as React$1 from 'react';
2
2
  import React__default from 'react';
3
3
  import * as LucideReactIcons from 'lucide-react';
4
4
  import * as react_native from 'react-native';
5
- import { ViewProps, ImageSourcePropType, StyleProp, ViewStyle, TextProps as TextProps$1, TextStyle, ImageProps, RefreshControl } from 'react-native';
5
+ import { ViewProps, ImageSourcePropType, StyleProp, ViewStyle, TextProps as TextProps$1, TextStyle, ImageProps, AccessibilityRole, RefreshControl } from 'react-native';
6
6
 
7
7
  declare const sizes: {
8
8
  readonly borderRadiusSm: 15;
@@ -116,6 +116,11 @@ declare enum TileHeight {
116
116
  Full = "FULL"
117
117
  }
118
118
  type ProgessType = 'NAME' | 'POINTS';
119
+ declare enum StatusVariant {
120
+ PRIMARY = "primary",
121
+ GREEN = "green",
122
+ GREY = "grey"
123
+ }
119
124
  declare class BannerTileConfig {
120
125
  artworkUrl?: string | null;
121
126
  title?: string | null;
@@ -514,6 +519,20 @@ type SpacerProps = {
514
519
  */
515
520
  declare const Spacer: ({ style, ...rest }: SpacerProps) => React__default.ReactElement;
516
521
 
522
+ type ChipLabel = React__default.ReactNode;
523
+ type AriaLive = 'polite' | 'assertive' | 'off';
524
+ type ChipProps = {
525
+ label: ChipLabel;
526
+ variant?: StatusVariant;
527
+ role?: AccessibilityRole | 'status';
528
+ ariaLive?: AriaLive;
529
+ accessibilityLabel?: string;
530
+ testID?: string;
531
+ style?: StyleProp<ViewStyle>;
532
+ labelStyle?: StyleProp<TextStyle>;
533
+ };
534
+ declare const Chip: ({ label, variant, role, ariaLive, accessibilityLabel, testID, style, labelStyle, }: ChipProps) => React__default.ReactElement;
535
+
517
536
  declare enum SectionType {
518
537
  Grid = "GRID",
519
538
  Banner = "BANNER"
@@ -747,4 +766,4 @@ declare function usePullToRefresh({ onRefresh, refreshing: externalRefreshing, }
747
766
  handleRefresh: () => Promise<void>;
748
767
  };
749
768
 
750
- 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, 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, 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 };
769
+ 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 };
package/dist/native.js CHANGED
@@ -947,16 +947,6 @@ var desaturateColor = function (color) {
947
947
  .lighten(COLOR_CONSTANTS.DESATURATION_LIGHTEN_AMOUNT)
948
948
  .toString();
949
949
  };
950
- /**
951
- * Gets the appropriate state color based on type and count
952
- * @param baseColor - Base color to process
953
- * @param type - Type of state
954
- * @param count - Count affecting the state
955
- * @returns Processed color string
956
- */
957
- var getStateColor = function (baseColor, type, count) {
958
- return shouldDesaturate(type, count) ? desaturateColor(baseColor) : baseColor;
959
- };
960
950
 
961
951
  var DIMENSION_MODES = {
962
952
  DESKTOP: 'desktop',
@@ -1541,6 +1531,12 @@ exports.TileHeight = void 0;
1541
1531
  TileHeight["Half"] = "HALF";
1542
1532
  TileHeight["Full"] = "FULL";
1543
1533
  })(exports.TileHeight || (exports.TileHeight = {}));
1534
+ exports.StatusVariant = void 0;
1535
+ (function (StatusVariant) {
1536
+ StatusVariant["PRIMARY"] = "primary";
1537
+ StatusVariant["GREEN"] = "green";
1538
+ StatusVariant["GREY"] = "grey";
1539
+ })(exports.StatusVariant || (exports.StatusVariant = {}));
1544
1540
  var BannerTileConfig = /** @class */ (function () {
1545
1541
  function BannerTileConfig() {
1546
1542
  }
@@ -2284,67 +2280,13 @@ var handleLastEarnedDate = function (date, userLocale) {
2284
2280
  }
2285
2281
  };
2286
2282
 
2287
- /**
2288
- * Custom hook that returns the styles for the BadgeTile component.
2289
- * Applies responsive styling based on the current device.
2290
- *
2291
- * @returns StyleSheet styles for the BadgeTile component
2292
- */
2293
- var useBadgeTileStyles = function () {
2294
- var _a = useResponsive$1(), isDesktop = _a.isDesktop, isTablet = _a.isTablet;
2295
- var theme = useWllSdk().theme;
2296
- return reactNative.StyleSheet.create({
2297
- container: {
2298
- flex: 1,
2299
- },
2300
- indicatorContainer: {
2301
- position: 'absolute',
2302
- bottom: useResponsiveValue(theme.sizes.lg, theme.sizes.xxs, isDesktop, isTablet),
2303
- right: useResponsiveValue(theme.sizes.lg, theme.sizes.xxs, isDesktop, isTablet),
2304
- backgroundColor: 'rgba(0,0,0,0.6)',
2305
- borderRadius: 40,
2306
- width: 40,
2307
- alignItems: 'center',
2308
- justifyContent: 'center',
2309
- height: 40,
2310
- },
2311
- countText: {
2312
- color: '#FFF',
2313
- fontSize: 14,
2314
- fontWeight: 'bold',
2315
- },
2316
- header: {
2317
- flexBasis: '50%',
2318
- alignItems: 'center',
2319
- justifyContent: 'center',
2320
- position: 'relative',
2321
- marginBottom: useResponsiveValue(theme.sizes.lg, theme.sizes.xxs, isDesktop, isTablet),
2322
- },
2323
- image: {
2324
- width: '100%',
2325
- height: '100%',
2326
- },
2327
- titleText: {
2328
- marginBottom: useResponsiveValue(theme.sizes.xxs, theme.sizes.xxxs, isDesktop, isTablet),
2329
- },
2330
- dateEarnedContainer: {
2331
- alignItems: 'flex-start',
2332
- paddingHorizontal: 8,
2333
- paddingVertical: 4,
2334
- borderRadius: 20,
2335
- },
2336
- });
2337
- };
2338
-
2339
2283
  /**
2340
2284
  * Renders the date earned for a Badge Tile.
2341
2285
  *
2342
2286
  * @returns React.ReactElement or null if badge is not earned or badgeNotEarnedMessage exists
2343
2287
  */
2344
2288
  var BadgeTileDateEarned = function () {
2345
- var styles = useBadgeTileStyles();
2346
2289
  var tileContext = useTileContext();
2347
- var theme = useWllSdk().theme;
2348
2290
  if (!isContextValid(tileContext))
2349
2291
  return null;
2350
2292
  var _a = tileContext.configuration, count = _a.count, awardedDatePrefix = _a.awardedDatePrefix, lastEarnedAt = _a.lastEarnedAt, badgeNotEarnedMessage = _a.badgeNotEarnedMessage, type = _a.type, locale = _a.locale;
@@ -2358,16 +2300,14 @@ var BadgeTileDateEarned = function () {
2358
2300
  !badgeNotEarnedMessage) {
2359
2301
  return null;
2360
2302
  }
2361
- var backgroundColor = getStateColor(theme.alphaDerivedPrimary[20], type, count);
2362
- var containerStyle = [styles.dateEarnedContainer, { backgroundColor: backgroundColor }];
2363
- var textColor = getReadableTextColor(backgroundColor);
2303
+ var formattedDate = handleLastEarnedDate(lastEarnedAt, locale);
2364
2304
  var displayText = count === 0
2365
2305
  ? badgeNotEarnedMessage
2366
- : "".concat(awardedDatePrefix, " ").concat(handleLastEarnedDate(lastEarnedAt, locale));
2306
+ : "".concat(awardedDatePrefix, " ").concat(formattedDate);
2367
2307
  var accessibilityLabel = count === 0
2368
2308
  ? 'Badge not yet earned'
2369
- : "Badge earned on ".concat(handleLastEarnedDate(lastEarnedAt, locale));
2370
- return (jsxRuntimeExports.jsx(reactNative.View, { style: containerStyle, accessible: true, accessibilityLabel: accessibilityLabel, testID: "badge-tile-date-earned", children: jsxRuntimeExports.jsx(Text, { variant: "label", style: [styles.dateEarnedText, { color: textColor }], numberOfLines: 1, ellipsizeMode: "tail", accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: displayText }) }));
2309
+ : "Badge earned on ".concat(formattedDate);
2310
+ return (jsxRuntimeExports.jsx(Chip, { label: displayText, variant: count === 0 ? exports.StatusVariant.GREY : exports.StatusVariant.PRIMARY, accessibilityLabel: accessibilityLabel, testID: "badge-tile-date-earned" }));
2371
2311
  };
2372
2312
 
2373
2313
  /**
@@ -2402,6 +2342,58 @@ var BadgeTileDescription = function () {
2402
2342
  }, children: jsxRuntimeExports.jsx(Text, { variant: "body", numberOfLines: numberOfLines, ellipsizeMode: "tail", accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: description }) }));
2403
2343
  };
2404
2344
 
2345
+ /**
2346
+ * Custom hook that returns the styles for the BadgeTile component.
2347
+ * Applies responsive styling based on the current device.
2348
+ *
2349
+ * @returns StyleSheet styles for the BadgeTile component
2350
+ */
2351
+ var useBadgeTileStyles = function () {
2352
+ var _a = useResponsive$1(), isDesktop = _a.isDesktop, isTablet = _a.isTablet;
2353
+ var theme = useWllSdk().theme;
2354
+ return reactNative.StyleSheet.create({
2355
+ container: {
2356
+ flex: 1,
2357
+ },
2358
+ indicatorContainer: {
2359
+ position: 'absolute',
2360
+ bottom: useResponsiveValue(theme.sizes.lg, theme.sizes.xxs, isDesktop, isTablet),
2361
+ right: useResponsiveValue(theme.sizes.lg, theme.sizes.xxs, isDesktop, isTablet),
2362
+ backgroundColor: 'rgba(0,0,0,0.6)',
2363
+ borderRadius: 40,
2364
+ width: 40,
2365
+ alignItems: 'center',
2366
+ justifyContent: 'center',
2367
+ height: 40,
2368
+ },
2369
+ countText: {
2370
+ color: '#FFF',
2371
+ fontSize: 14,
2372
+ fontWeight: 'bold',
2373
+ },
2374
+ header: {
2375
+ flexBasis: '50%',
2376
+ alignItems: 'center',
2377
+ justifyContent: 'center',
2378
+ position: 'relative',
2379
+ marginBottom: useResponsiveValue(theme.sizes.lg, theme.sizes.xxs, isDesktop, isTablet),
2380
+ },
2381
+ image: {
2382
+ width: '100%',
2383
+ height: '100%',
2384
+ },
2385
+ titleText: {
2386
+ marginBottom: useResponsiveValue(theme.sizes.xxs, theme.sizes.xxxs, isDesktop, isTablet),
2387
+ },
2388
+ dateEarnedContainer: {
2389
+ alignItems: 'flex-start',
2390
+ paddingHorizontal: 8,
2391
+ paddingVertical: 4,
2392
+ borderRadius: 20,
2393
+ },
2394
+ });
2395
+ };
2396
+
2405
2397
  /**
2406
2398
  * Renders the media for a Badge Tile.
2407
2399
  *
@@ -4481,6 +4473,81 @@ var styles = reactNative.StyleSheet.create({
4481
4473
  },
4482
4474
  });
4483
4475
 
4476
+ var useChipStyles = function () {
4477
+ var theme = useWllSdk().theme;
4478
+ var _a = useResponsive$1(), isDesktop = _a.isDesktop, isTablet = _a.isTablet;
4479
+ var paddingHorizontal = useResponsiveValue(12, 8, isDesktop, isTablet);
4480
+ var paddingVertical = useResponsiveValue(6, 3, isDesktop, isTablet);
4481
+ var fontSize = useResponsiveValue(theme.sizes.sm, theme.sizes.xs, isDesktop, isTablet);
4482
+ var lineHeight = Math.max(fontSize, Math.round(fontSize * 1.3));
4483
+ return reactNative.StyleSheet.create({
4484
+ container: {
4485
+ alignSelf: 'flex-start',
4486
+ alignItems: 'center',
4487
+ justifyContent: 'center',
4488
+ flexDirection: 'row',
4489
+ paddingHorizontal: paddingHorizontal,
4490
+ paddingVertical: paddingVertical,
4491
+ borderRadius: theme.sizes.borderRadiusRounded,
4492
+ overflow: 'hidden',
4493
+ flexShrink: 1,
4494
+ },
4495
+ label: {
4496
+ fontFamily: theme.fontFamily,
4497
+ fontSize: fontSize,
4498
+ lineHeight: lineHeight,
4499
+ fontWeight: '400',
4500
+ flexShrink: 1,
4501
+ },
4502
+ });
4503
+ };
4504
+
4505
+ var mapLiveRegion = function (ariaLive) {
4506
+ if (ariaLive === void 0) { ariaLive = 'polite'; }
4507
+ switch (ariaLive) {
4508
+ case 'assertive':
4509
+ return { native: 'assertive', web: 'assertive' };
4510
+ case 'off':
4511
+ return { native: 'none', web: 'off' };
4512
+ case 'polite':
4513
+ default:
4514
+ return { native: 'polite', web: 'polite' };
4515
+ }
4516
+ };
4517
+ var Chip = function (_a) {
4518
+ var label = _a.label, _b = _a.variant, variant = _b === void 0 ? exports.StatusVariant.PRIMARY : _b, _c = _a.role, role = _c === void 0 ? 'status' : _c, _d = _a.ariaLive, ariaLive = _d === void 0 ? 'polite' : _d, accessibilityLabel = _a.accessibilityLabel, testID = _a.testID, style = _a.style, labelStyle = _a.labelStyle;
4519
+ var styles = useChipStyles();
4520
+ var theme = useWllSdk().theme;
4521
+ var variantStyles = React.useMemo(function () {
4522
+ var _a, _b;
4523
+ switch (variant) {
4524
+ case exports.StatusVariant.GREEN:
4525
+ return {
4526
+ container: { backgroundColor: '#d1f0e1' },
4527
+ label: { color: '#128e55' },
4528
+ };
4529
+ case exports.StatusVariant.GREY:
4530
+ return {
4531
+ container: { backgroundColor: '#dadde0' },
4532
+ label: { color: '#666666' },
4533
+ };
4534
+ case exports.StatusVariant.PRIMARY:
4535
+ default:
4536
+ return {
4537
+ container: {
4538
+ backgroundColor: (_b = (_a = theme.alphaDerivedPrimary) === null || _a === void 0 ? void 0 : _a[10]) !== null && _b !== void 0 ? _b : theme.primary,
4539
+ },
4540
+ label: { color: theme.primary },
4541
+ };
4542
+ }
4543
+ }, [theme, variant]);
4544
+ var computedAccessibilityLabel = accessibilityLabel !== null && accessibilityLabel !== void 0 ? accessibilityLabel : (typeof label === 'string' ? label : undefined);
4545
+ var _e = mapLiveRegion(ariaLive), accessibilityLiveRegion = _e.native, ariaLiveValue = _e.web;
4546
+ var isSimpleLabel = typeof label === 'string';
4547
+ var isIndividuallyAccessible = computedAccessibilityLabel !== undefined;
4548
+ return (jsxRuntimeExports.jsx(reactNative.View, { style: [styles.container, variantStyles.container, style], accessible: isIndividuallyAccessible, accessibilityRole: role, accessibilityLiveRegion: accessibilityLiveRegion, accessibilityLabel: computedAccessibilityLabel, "aria-live": ariaLiveValue, testID: testID, children: isSimpleLabel ? (jsxRuntimeExports.jsx(reactNative.Text, { style: [styles.label, variantStyles.label, labelStyle], numberOfLines: 1, ellipsizeMode: "tail", accessible: false, importantForAccessibility: "no", children: label })) : (label) }));
4549
+ };
4550
+
4484
4551
  var Reward = /** @class */ (function () {
4485
4552
  function Reward() {
4486
4553
  }
@@ -4496,6 +4563,7 @@ exports.BaseTile = BaseTile;
4496
4563
  exports.Button = Button;
4497
4564
  exports.Carousel = Carousel;
4498
4565
  exports.CarouselNavButton = CarouselNavButton;
4566
+ exports.Chip = Chip;
4499
4567
  exports.Column = Column;
4500
4568
  exports.ContentTile = ContentTile$1;
4501
4569
  exports.ContentTileConfig = ContentTileConfig;