@wlloyalty/wll-react-sdk 1.0.99 → 1.0.101

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
@@ -677,6 +677,7 @@ type WllSdkContextType = ThemeContextType & {
677
677
  getSectionByID: (id: string) => Promise<APIResponse<TSection>>;
678
678
  getTileByID: (id: string) => Promise<APIResponse<Tile>>;
679
679
  handleNavigation: (link: string, target: CTALinkTarget) => Promise<void>;
680
+ refreshGroup: (id: string) => Promise<APIResponse<TGroup>>;
680
681
  } & Readonly<{
681
682
  readonly config: SDKConfig;
682
683
  }>;
package/dist/native.js CHANGED
@@ -1699,9 +1699,6 @@ var validateTheme = function (theme) {
1699
1699
  var createSafeColor = function (color) {
1700
1700
  try {
1701
1701
  var colorInstance = Color(color);
1702
- console.log('Original color:', color);
1703
- console.log('Color instance toString:', colorInstance.toString());
1704
- console.log('Color instance hex:', colorInstance.hex());
1705
1702
  return colorInstance;
1706
1703
  }
1707
1704
  catch (error) {
@@ -1959,6 +1956,11 @@ var WllSdkProvider = function (_a) {
1959
1956
  var getSectionByID = useGetSectionByID(config);
1960
1957
  var getTileByID = useGetTileByID(config);
1961
1958
  var handleNavigation = useNavigation(navigationConfig);
1959
+ var refreshGroup = React.useCallback(function (id) { return __awaiter(void 0, void 0, void 0, function () {
1960
+ return __generator(this, function (_a) {
1961
+ return [2 /*return*/, getGroupByID(id)];
1962
+ });
1963
+ }); }, [getGroupByID]);
1962
1964
  var contextValue = React.useMemo(function () { return ({
1963
1965
  theme: theme,
1964
1966
  setTheme: setTheme,
@@ -1966,6 +1968,7 @@ var WllSdkProvider = function (_a) {
1966
1968
  getSectionByID: getSectionByID,
1967
1969
  getTileByID: getTileByID,
1968
1970
  handleNavigation: handleNavigation,
1971
+ refreshGroup: refreshGroup,
1969
1972
  config: config,
1970
1973
  }); }, [
1971
1974
  theme,
@@ -1974,6 +1977,7 @@ var WllSdkProvider = function (_a) {
1974
1977
  getSectionByID,
1975
1978
  getTileByID,
1976
1979
  handleNavigation,
1980
+ refreshGroup,
1977
1981
  config,
1978
1982
  ]);
1979
1983
  return (jsxRuntimeExports.jsx(WllSdkContext.Provider, { value: contextValue, children: jsxRuntimeExports.jsx(ResponsiveProvider, { children: children }) }));
@@ -2311,11 +2315,33 @@ var Text = function (_a) {
2311
2315
  }
2312
2316
  };
2313
2317
  var variantStyle = getVariantStyle(variant);
2314
- var baseTextStyle = {
2315
- fontFamily: theme.fontFamily,
2316
- };
2317
- // NOTE: We must apply fontFamily as base style to ensure it's always applied
2318
- return jsxRuntimeExports.jsx(reactNative.Text, __assign({ style: [baseTextStyle, variantStyle, style] }, props));
2318
+ // NOTE: React Native Web has different style resolution rules compared to CSS.
2319
+ // 1. We create styles using StyleSheet.create for better performance
2320
+ // 2. Base styles set the initial fontFamily
2321
+ // 3. variantStyle contains responsive fontSize and other variant-specific styles
2322
+ // 4. webOverrides ensures fontFamily is correctly applied on web platform
2323
+ // (prevents system font stack from being incorrectly applied)
2324
+ // 5. custom style prop has highest precedence
2325
+ // The order matters because RN Web resolves styles by specific properties
2326
+ // rather than last-declaration-wins like in CSS
2327
+ // https://necolas.github.io/react-native-web/docs/styling/#how-it-works
2328
+ var styles = reactNative.StyleSheet.create({
2329
+ base: {
2330
+ fontFamily: theme.fontFamily,
2331
+ },
2332
+ webOverrides: IS_WEB
2333
+ ? {
2334
+ fontFamily: theme.fontFamily,
2335
+ }
2336
+ : {},
2337
+ });
2338
+ var combinedStyles = [
2339
+ styles.base,
2340
+ variantStyle,
2341
+ styles.webOverrides,
2342
+ style,
2343
+ ];
2344
+ return jsxRuntimeExports.jsx(reactNative.Text, __assign({ style: combinedStyles }, props));
2319
2345
  };
2320
2346
 
2321
2347
  var MAX_WIDTH = 1080;
@@ -4032,47 +4058,61 @@ var useGroupData = function (id) {
4032
4058
  var _a = React.useState(null), groupData = _a[0], setGroupData = _a[1];
4033
4059
  var _b = React.useState(null), error = _b[0], setError = _b[1];
4034
4060
  var _c = React.useState(true), isLoading = _c[0], setIsLoading = _c[1];
4035
- var fetchGroup = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
4036
- var response, err_1;
4037
- return __generator(this, function (_a) {
4038
- switch (_a.label) {
4039
- case 0:
4040
- if (!id || !sdk || !sdk.getGroupByID) {
4041
- setError('Unable to fetch group data: invalid configuration');
4042
- setIsLoading(false);
4043
- return [2 /*return*/];
4044
- }
4045
- setIsLoading(true);
4046
- setError(null);
4047
- _a.label = 1;
4048
- case 1:
4049
- _a.trys.push([1, 3, 4, 5]);
4050
- return [4 /*yield*/, sdk.getGroupByID(id)];
4051
- case 2:
4052
- response = _a.sent();
4053
- if (response && response.status === 'success' && response.data) {
4054
- setGroupData(response.data);
4055
- }
4056
- else {
4057
- setError((response && response.error) || 'Failed to fetch group data.');
4058
- }
4059
- return [3 /*break*/, 5];
4060
- case 3:
4061
- err_1 = _a.sent();
4062
- setError('Failed to fetch group data. Please try again later.');
4063
- console.error('Error fetching group:', err_1);
4064
- return [3 /*break*/, 5];
4065
- case 4:
4066
- setIsLoading(false);
4067
- return [7 /*endfinally*/];
4068
- case 5: return [2 /*return*/];
4069
- }
4061
+ var fetchGroup = React.useCallback(function () {
4062
+ var args_1 = [];
4063
+ for (var _i = 0; _i < arguments.length; _i++) {
4064
+ args_1[_i] = arguments[_i];
4065
+ }
4066
+ return __awaiter(void 0, __spreadArray([], args_1, true), void 0, function (showLoading) {
4067
+ var response, err_1;
4068
+ if (showLoading === void 0) { showLoading = true; }
4069
+ return __generator(this, function (_a) {
4070
+ switch (_a.label) {
4071
+ case 0:
4072
+ if (!id || !sdk || !sdk.getGroupByID) {
4073
+ setError('Unable to fetch group data: invalid configuration');
4074
+ setIsLoading(false);
4075
+ return [2 /*return*/];
4076
+ }
4077
+ if (showLoading) {
4078
+ setIsLoading(true);
4079
+ }
4080
+ setError(null);
4081
+ _a.label = 1;
4082
+ case 1:
4083
+ _a.trys.push([1, 3, 4, 5]);
4084
+ return [4 /*yield*/, sdk.refreshGroup(id)];
4085
+ case 2:
4086
+ response = _a.sent();
4087
+ if (response && response.status === 'success' && response.data) {
4088
+ setGroupData(response.data);
4089
+ }
4090
+ else {
4091
+ setError((response && response.error) || 'Failed to fetch group data.');
4092
+ }
4093
+ return [3 /*break*/, 5];
4094
+ case 3:
4095
+ err_1 = _a.sent();
4096
+ setError('Failed to fetch group data. Please try again later.');
4097
+ console.error('Error fetching group:', err_1);
4098
+ return [3 /*break*/, 5];
4099
+ case 4:
4100
+ if (showLoading) {
4101
+ setIsLoading(false);
4102
+ }
4103
+ return [7 /*endfinally*/];
4104
+ case 5: return [2 /*return*/];
4105
+ }
4106
+ });
4070
4107
  });
4071
- }); }, [id, sdk]);
4108
+ }, [id, sdk]);
4109
+ var refreshGroup = React.useCallback(function () {
4110
+ return fetchGroup(false);
4111
+ }, [fetchGroup]);
4072
4112
  React.useEffect(function () {
4073
- fetchGroup();
4113
+ fetchGroup(true);
4074
4114
  }, [fetchGroup]);
4075
- return { groupData: groupData, isLoading: isLoading, error: error };
4115
+ return { groupData: groupData, isLoading: isLoading, error: error, refreshGroup: refreshGroup };
4076
4116
  };
4077
4117
  /**
4078
4118
  * Component to display an empty state with a message