@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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import { Meta } from '@storybook/react';
2
+ import Chip, { ChipProps } from './index';
3
+ declare const meta: Meta<typeof Chip>;
4
+ export default meta;
5
+ export declare const Primary: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, ChipProps>;
6
+ export declare const Green: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, ChipProps>;
7
+ export declare const Grey: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, ChipProps>;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { AccessibilityRole, StyleProp, TextStyle, ViewStyle } from 'react-native';
3
+ import { StatusVariant } from '../../../types/tile';
4
+ type ChipLabel = React.ReactNode;
5
+ type AriaLive = 'polite' | 'assertive' | 'off';
6
+ export type ChipProps = {
7
+ label: ChipLabel;
8
+ variant?: StatusVariant;
9
+ role?: AccessibilityRole | 'status';
10
+ ariaLive?: AriaLive;
11
+ accessibilityLabel?: string;
12
+ testID?: string;
13
+ style?: StyleProp<ViewStyle>;
14
+ labelStyle?: StyleProp<TextStyle>;
15
+ };
16
+ declare const Chip: ({ label, variant, role, ariaLive, accessibilityLabel, testID, style, labelStyle, }: ChipProps) => React.ReactElement;
17
+ export default Chip;
@@ -0,0 +1,20 @@
1
+ export declare const useChipStyles: () => {
2
+ container: {
3
+ alignSelf: "flex-start";
4
+ alignItems: "center";
5
+ justifyContent: "center";
6
+ flexDirection: "row";
7
+ paddingHorizontal: number;
8
+ paddingVertical: number;
9
+ borderRadius: 9999;
10
+ overflow: "hidden";
11
+ flexShrink: number;
12
+ };
13
+ label: {
14
+ fontFamily: string;
15
+ fontSize: number;
16
+ lineHeight: number;
17
+ fontWeight: "400";
18
+ flexShrink: number;
19
+ };
20
+ };
@@ -10,3 +10,4 @@ export { default as Indicator } from './Indicator';
10
10
  export { default as Skeleton } from './Skeleton';
11
11
  export { default as TileContainer } from './TileContainer';
12
12
  export { Column, FullFlex, Layout, Row, Spacer } from './Primatives';
13
+ export { default as Chip } from './Chip';
@@ -26,6 +26,11 @@ export declare enum TileHeight {
26
26
  Full = "FULL"
27
27
  }
28
28
  export type ProgessType = 'NAME' | 'POINTS';
29
+ export declare enum StatusVariant {
30
+ PRIMARY = "primary",
31
+ GREEN = "green",
32
+ GREY = "grey"
33
+ }
29
34
  export declare class BannerTileConfig {
30
35
  artworkUrl?: string | null;
31
36
  title?: string | null;
package/dist/web.js CHANGED
@@ -7706,7 +7706,7 @@ var styles$g = StyleSheet$1.create({
7706
7706
  cursor: 'pointer'
7707
7707
  }
7708
7708
  });
7709
- var Text$3 = Text$2;
7709
+ var RNText = Text$2;
7710
7710
 
7711
7711
  /******************************************************************************
7712
7712
  Copyright (c) Microsoft Corporation.
@@ -8443,16 +8443,6 @@ var desaturateColor = function (color) {
8443
8443
  if (!baseColor) return COLOR_CONSTANTS.DEFAULT_COLOR;
8444
8444
  return baseColor.grayscale().lighten(COLOR_CONSTANTS.DESATURATION_LIGHTEN_AMOUNT).toString();
8445
8445
  };
8446
- /**
8447
- * Gets the appropriate state color based on type and count
8448
- * @param baseColor - Base color to process
8449
- * @param type - Type of state
8450
- * @param count - Count affecting the state
8451
- * @returns Processed color string
8452
- */
8453
- var getStateColor = function (baseColor, type, count) {
8454
- return shouldDesaturate(type, count) ? desaturateColor(baseColor) : baseColor;
8455
- };
8456
8446
 
8457
8447
  var DIMENSION_MODES = {
8458
8448
  DESKTOP: 'desktop',
@@ -8806,7 +8796,7 @@ var Button = function (_a) {
8806
8796
  disabled: disabled
8807
8797
  },
8808
8798
  testID: testID
8809
- }, /*#__PURE__*/React__namespace.createElement(Text$3, {
8799
+ }, /*#__PURE__*/React__namespace.createElement(RNText, {
8810
8800
  style: [styles.text, textStyle]
8811
8801
  }, title));
8812
8802
  };
@@ -16417,7 +16407,7 @@ var SectionList = createAnimatedComponent(SectionListWithEventThrottle);
16417
16407
  * @format
16418
16408
  */
16419
16409
 
16420
- var Text$1 = createAnimatedComponent(Text$3);
16410
+ var Text$1 = createAnimatedComponent(RNText);
16421
16411
 
16422
16412
  /**
16423
16413
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -19064,7 +19054,7 @@ var Text = function (_a) {
19064
19054
  accessibilityRole = IS_MOBILE ? 'contentinfo' : 'text';
19065
19055
  }
19066
19056
  var combinedStyles = [styles.base, variantStyle, styles.webOverrides, style];
19067
- return /*#__PURE__*/React__namespace.createElement(Text$3, __assign({
19057
+ return /*#__PURE__*/React__namespace.createElement(RNText, __assign({
19068
19058
  style: combinedStyles
19069
19059
  }, props, {
19070
19060
  accessible: true,
@@ -19106,6 +19096,12 @@ exports.TileHeight = void 0;
19106
19096
  TileHeight["Half"] = "HALF";
19107
19097
  TileHeight["Full"] = "FULL";
19108
19098
  })(exports.TileHeight || (exports.TileHeight = {}));
19099
+ exports.StatusVariant = void 0;
19100
+ (function (StatusVariant) {
19101
+ StatusVariant["PRIMARY"] = "primary";
19102
+ StatusVariant["GREEN"] = "green";
19103
+ StatusVariant["GREY"] = "grey";
19104
+ })(exports.StatusVariant || (exports.StatusVariant = {}));
19109
19105
  var BannerTileConfig = /** @class */function () {
19110
19106
  function BannerTileConfig() {}
19111
19107
  return BannerTileConfig;
@@ -19671,7 +19667,7 @@ var Indicator = function () {
19671
19667
  };
19672
19668
  return /*#__PURE__*/React.createElement(View$2, {
19673
19669
  style: styles$5.indicator
19674
- }, /*#__PURE__*/React.createElement(Text$3, {
19670
+ }, /*#__PURE__*/React.createElement(RNText, {
19675
19671
  style: styles$5.indicatorText
19676
19672
  }, getCurrentLayout()));
19677
19673
  };
@@ -19916,7 +19912,7 @@ function withTileFetching(WrappedComponent) {
19916
19912
  if (error || !tileData) {
19917
19913
  return /*#__PURE__*/React.createElement(View$2, {
19918
19914
  style: commonStyles.emptyContainer
19919
- }, /*#__PURE__*/React.createElement(Text$3, null, "No tile data available"));
19915
+ }, /*#__PURE__*/React.createElement(RNText, null, "No tile data available"));
19920
19916
  }
19921
19917
  return /*#__PURE__*/React.createElement(WrappedComponent, __assign({}, props, {
19922
19918
  tile: tileData
@@ -19981,69 +19977,13 @@ var handleLastEarnedDate = function (date, userLocale) {
19981
19977
  }
19982
19978
  };
19983
19979
 
19984
- /**
19985
- * Custom hook that returns the styles for the BadgeTile component.
19986
- * Applies responsive styling based on the current device.
19987
- *
19988
- * @returns StyleSheet styles for the BadgeTile component
19989
- */
19990
- var useBadgeTileStyles = function () {
19991
- var _a = useResponsive$1(),
19992
- isDesktop = _a.isDesktop,
19993
- isTablet = _a.isTablet;
19994
- var theme = useWllSdk().theme;
19995
- return StyleSheet$1.create({
19996
- container: {
19997
- flex: 1
19998
- },
19999
- indicatorContainer: {
20000
- position: 'absolute',
20001
- bottom: useResponsiveValue(theme.sizes.lg, theme.sizes.xxs, isDesktop, isTablet),
20002
- right: useResponsiveValue(theme.sizes.lg, theme.sizes.xxs, isDesktop, isTablet),
20003
- backgroundColor: 'rgba(0,0,0,0.6)',
20004
- borderRadius: 40,
20005
- width: 40,
20006
- alignItems: 'center',
20007
- justifyContent: 'center',
20008
- height: 40
20009
- },
20010
- countText: {
20011
- color: '#FFF',
20012
- fontSize: 14,
20013
- fontWeight: 'bold'
20014
- },
20015
- header: {
20016
- flexBasis: '50%',
20017
- alignItems: 'center',
20018
- justifyContent: 'center',
20019
- position: 'relative',
20020
- marginBottom: useResponsiveValue(theme.sizes.lg, theme.sizes.xxs, isDesktop, isTablet)
20021
- },
20022
- image: {
20023
- width: '100%',
20024
- height: '100%'
20025
- },
20026
- titleText: {
20027
- marginBottom: useResponsiveValue(theme.sizes.xxs, theme.sizes.xxxs, isDesktop, isTablet)
20028
- },
20029
- dateEarnedContainer: {
20030
- alignItems: 'flex-start',
20031
- paddingHorizontal: 8,
20032
- paddingVertical: 4,
20033
- borderRadius: 20
20034
- }
20035
- });
20036
- };
20037
-
20038
19980
  /**
20039
19981
  * Renders the date earned for a Badge Tile.
20040
19982
  *
20041
19983
  * @returns React.ReactElement or null if badge is not earned or badgeNotEarnedMessage exists
20042
19984
  */
20043
19985
  var BadgeTileDateEarned = function () {
20044
- var styles = useBadgeTileStyles();
20045
19986
  var tileContext = useTileContext();
20046
- var theme = useWllSdk().theme;
20047
19987
  if (!isContextValid(tileContext)) return null;
20048
19988
  var _a = tileContext.configuration,
20049
19989
  count = _a.count,
@@ -20060,28 +20000,15 @@ var BadgeTileDateEarned = function () {
20060
20000
  if (type === exports.BadgeTileType.Specific && count === 0 && !badgeNotEarnedMessage) {
20061
20001
  return null;
20062
20002
  }
20063
- var backgroundColor = getStateColor(theme.alphaDerivedPrimary[20], type, count);
20064
- var containerStyle = [styles.dateEarnedContainer, {
20065
- backgroundColor: backgroundColor
20066
- }];
20067
- var textColor = getReadableTextColor(backgroundColor);
20068
- var displayText = count === 0 ? badgeNotEarnedMessage : "".concat(awardedDatePrefix, " ").concat(handleLastEarnedDate(lastEarnedAt, locale));
20069
- var accessibilityLabel = count === 0 ? 'Badge not yet earned' : "Badge earned on ".concat(handleLastEarnedDate(lastEarnedAt, locale));
20070
- return /*#__PURE__*/React.createElement(View$2, {
20071
- style: containerStyle,
20072
- accessible: true,
20003
+ var formattedDate = handleLastEarnedDate(lastEarnedAt, locale);
20004
+ var displayText = count === 0 ? badgeNotEarnedMessage : "".concat(awardedDatePrefix, " ").concat(formattedDate);
20005
+ var accessibilityLabel = count === 0 ? 'Badge not yet earned' : "Badge earned on ".concat(formattedDate);
20006
+ return /*#__PURE__*/React.createElement(Chip, {
20007
+ label: displayText,
20008
+ variant: count === 0 ? exports.StatusVariant.GREY : exports.StatusVariant.PRIMARY,
20073
20009
  accessibilityLabel: accessibilityLabel,
20074
20010
  testID: "badge-tile-date-earned"
20075
- }, /*#__PURE__*/React.createElement(Text, {
20076
- variant: "label",
20077
- style: [styles.dateEarnedText, {
20078
- color: textColor
20079
- }],
20080
- numberOfLines: 1,
20081
- ellipsizeMode: "tail",
20082
- accessibilityElementsHidden: true,
20083
- importantForAccessibility: "no-hide-descendants"
20084
- }, displayText));
20011
+ });
20085
20012
  };
20086
20013
 
20087
20014
  /**
@@ -20124,6 +20051,60 @@ var BadgeTileDescription = function () {
20124
20051
  }, description));
20125
20052
  };
20126
20053
 
20054
+ /**
20055
+ * Custom hook that returns the styles for the BadgeTile component.
20056
+ * Applies responsive styling based on the current device.
20057
+ *
20058
+ * @returns StyleSheet styles for the BadgeTile component
20059
+ */
20060
+ var useBadgeTileStyles = function () {
20061
+ var _a = useResponsive$1(),
20062
+ isDesktop = _a.isDesktop,
20063
+ isTablet = _a.isTablet;
20064
+ var theme = useWllSdk().theme;
20065
+ return StyleSheet$1.create({
20066
+ container: {
20067
+ flex: 1
20068
+ },
20069
+ indicatorContainer: {
20070
+ position: 'absolute',
20071
+ bottom: useResponsiveValue(theme.sizes.lg, theme.sizes.xxs, isDesktop, isTablet),
20072
+ right: useResponsiveValue(theme.sizes.lg, theme.sizes.xxs, isDesktop, isTablet),
20073
+ backgroundColor: 'rgba(0,0,0,0.6)',
20074
+ borderRadius: 40,
20075
+ width: 40,
20076
+ alignItems: 'center',
20077
+ justifyContent: 'center',
20078
+ height: 40
20079
+ },
20080
+ countText: {
20081
+ color: '#FFF',
20082
+ fontSize: 14,
20083
+ fontWeight: 'bold'
20084
+ },
20085
+ header: {
20086
+ flexBasis: '50%',
20087
+ alignItems: 'center',
20088
+ justifyContent: 'center',
20089
+ position: 'relative',
20090
+ marginBottom: useResponsiveValue(theme.sizes.lg, theme.sizes.xxs, isDesktop, isTablet)
20091
+ },
20092
+ image: {
20093
+ width: '100%',
20094
+ height: '100%'
20095
+ },
20096
+ titleText: {
20097
+ marginBottom: useResponsiveValue(theme.sizes.xxs, theme.sizes.xxxs, isDesktop, isTablet)
20098
+ },
20099
+ dateEarnedContainer: {
20100
+ alignItems: 'flex-start',
20101
+ paddingHorizontal: 8,
20102
+ paddingVertical: 4,
20103
+ borderRadius: 20
20104
+ }
20105
+ });
20106
+ };
20107
+
20127
20108
  /**
20128
20109
  * Renders the media for a Badge Tile.
20129
20110
  *
@@ -21455,7 +21436,7 @@ var EmptyState = function (_a) {
21455
21436
  style: commonStyles.emptyContainer,
21456
21437
  role: "article",
21457
21438
  accessibilityLabel: "Empty state: ".concat(message)
21458
- }, /*#__PURE__*/React.createElement(Text$3, null, message));
21439
+ }, /*#__PURE__*/React.createElement(RNText, null, message));
21459
21440
  };
21460
21441
  /**
21461
21442
  * The Section component renders a section based on its type (e.g., Banner, Grid).
@@ -22918,6 +22899,130 @@ var styles = StyleSheet$1.create({
22918
22899
  }
22919
22900
  });
22920
22901
 
22902
+ var useChipStyles = function () {
22903
+ var theme = useWllSdk().theme;
22904
+ var _a = useResponsive$1(),
22905
+ isDesktop = _a.isDesktop,
22906
+ isTablet = _a.isTablet;
22907
+ var paddingHorizontal = useResponsiveValue(12, 8, isDesktop, isTablet);
22908
+ var paddingVertical = useResponsiveValue(6, 3, isDesktop, isTablet);
22909
+ var fontSize = useResponsiveValue(theme.sizes.sm, theme.sizes.xs, isDesktop, isTablet);
22910
+ var lineHeight = Math.max(fontSize, Math.round(fontSize * 1.3));
22911
+ return StyleSheet$1.create({
22912
+ container: {
22913
+ alignSelf: 'flex-start',
22914
+ alignItems: 'center',
22915
+ justifyContent: 'center',
22916
+ flexDirection: 'row',
22917
+ paddingHorizontal: paddingHorizontal,
22918
+ paddingVertical: paddingVertical,
22919
+ borderRadius: theme.sizes.borderRadiusRounded,
22920
+ overflow: 'hidden',
22921
+ flexShrink: 1
22922
+ },
22923
+ label: {
22924
+ fontFamily: theme.fontFamily,
22925
+ fontSize: fontSize,
22926
+ lineHeight: lineHeight,
22927
+ fontWeight: '400',
22928
+ flexShrink: 1
22929
+ }
22930
+ });
22931
+ };
22932
+
22933
+ var mapLiveRegion = function (ariaLive) {
22934
+ if (ariaLive === void 0) {
22935
+ ariaLive = 'polite';
22936
+ }
22937
+ switch (ariaLive) {
22938
+ case 'assertive':
22939
+ return {
22940
+ native: 'assertive',
22941
+ web: 'assertive'
22942
+ };
22943
+ case 'off':
22944
+ return {
22945
+ native: 'none',
22946
+ web: 'off'
22947
+ };
22948
+ case 'polite':
22949
+ default:
22950
+ return {
22951
+ native: 'polite',
22952
+ web: 'polite'
22953
+ };
22954
+ }
22955
+ };
22956
+ var Chip = function (_a) {
22957
+ var label = _a.label,
22958
+ _b = _a.variant,
22959
+ variant = _b === void 0 ? exports.StatusVariant.PRIMARY : _b,
22960
+ _c = _a.role,
22961
+ role = _c === void 0 ? 'status' : _c,
22962
+ _d = _a.ariaLive,
22963
+ ariaLive = _d === void 0 ? 'polite' : _d,
22964
+ accessibilityLabel = _a.accessibilityLabel,
22965
+ testID = _a.testID,
22966
+ style = _a.style,
22967
+ labelStyle = _a.labelStyle;
22968
+ var styles = useChipStyles();
22969
+ var theme = useWllSdk().theme;
22970
+ var variantStyles = React.useMemo(function () {
22971
+ var _a, _b;
22972
+ switch (variant) {
22973
+ case exports.StatusVariant.GREEN:
22974
+ return {
22975
+ container: {
22976
+ backgroundColor: '#d1f0e1'
22977
+ },
22978
+ label: {
22979
+ color: '#128e55'
22980
+ }
22981
+ };
22982
+ case exports.StatusVariant.GREY:
22983
+ return {
22984
+ container: {
22985
+ backgroundColor: '#dadde0'
22986
+ },
22987
+ label: {
22988
+ color: '#666666'
22989
+ }
22990
+ };
22991
+ case exports.StatusVariant.PRIMARY:
22992
+ default:
22993
+ return {
22994
+ container: {
22995
+ backgroundColor: (_b = (_a = theme.alphaDerivedPrimary) === null || _a === void 0 ? void 0 : _a[10]) !== null && _b !== void 0 ? _b : theme.primary
22996
+ },
22997
+ label: {
22998
+ color: theme.primary
22999
+ }
23000
+ };
23001
+ }
23002
+ }, [theme, variant]);
23003
+ var computedAccessibilityLabel = accessibilityLabel !== null && accessibilityLabel !== void 0 ? accessibilityLabel : typeof label === 'string' ? label : undefined;
23004
+ var _e = mapLiveRegion(ariaLive),
23005
+ accessibilityLiveRegion = _e.native,
23006
+ ariaLiveValue = _e.web;
23007
+ var isSimpleLabel = typeof label === 'string';
23008
+ var isIndividuallyAccessible = computedAccessibilityLabel !== undefined;
23009
+ return /*#__PURE__*/React.createElement(View$2, {
23010
+ style: [styles.container, variantStyles.container, style],
23011
+ accessible: isIndividuallyAccessible,
23012
+ accessibilityRole: role,
23013
+ accessibilityLiveRegion: accessibilityLiveRegion,
23014
+ accessibilityLabel: computedAccessibilityLabel,
23015
+ "aria-live": ariaLiveValue,
23016
+ testID: testID
23017
+ }, isSimpleLabel ? (/*#__PURE__*/React.createElement(RNText, {
23018
+ style: [styles.label, variantStyles.label, labelStyle],
23019
+ numberOfLines: 1,
23020
+ ellipsizeMode: "tail",
23021
+ accessible: false,
23022
+ importantForAccessibility: "no"
23023
+ }, label)) : label);
23024
+ };
23025
+
22921
23026
  var Reward = /** @class */function () {
22922
23027
  function Reward() {}
22923
23028
  return Reward;
@@ -22932,6 +23037,7 @@ exports.BaseTile = BaseTile;
22932
23037
  exports.Button = Button;
22933
23038
  exports.Carousel = Carousel;
22934
23039
  exports.CarouselNavButton = CarouselNavButton;
23040
+ exports.Chip = Chip;
22935
23041
  exports.Column = Column;
22936
23042
  exports.ContentTile = ContentTile$1;
22937
23043
  exports.ContentTileConfig = ContentTileConfig;