@wlloyalty/wll-react-sdk 1.0.30 → 1.0.33

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/README.md CHANGED
@@ -88,6 +88,26 @@ yarn commit
88
88
  yarn prepare
89
89
  ```
90
90
 
91
+ ### Creating New Components
92
+
93
+ We provide an interactive component generator to help maintain consistent structure. To create a new component:
94
+
95
+ ```bash
96
+ yarn create-component
97
+ ```
98
+
99
+ You'll be prompted for:
100
+ 1. Component name - The name of your new component
101
+ 2. Component type - Choose from:
102
+ - atoms: Basic building blocks
103
+ - molecules: Simple combinations of atoms
104
+ - organisms: Complex combinations of molecules
105
+ - particles: Smallest UI elements
106
+ - templates: Page-level components
107
+ 3. Base directory - Where to create the component (defaults to ./lib/components)
108
+
109
+ The script will generate a new component with the proper file structure and boilerplate code.
110
+
91
111
  ## 📄 License
92
112
 
93
113
  MIT License - See [LICENSE](LICENSE) for more information.
package/dist/index.js CHANGED
@@ -18870,7 +18870,6 @@ MemoedPressable.displayName = 'Pressable';
18870
18870
  var Pressable$1 = MemoedPressable;
18871
18871
 
18872
18872
  var MAX_WIDTH = 1080;
18873
- var SLIDE_WIDTH = MAX_WIDTH;
18874
18873
  var BUTTON_SIZE = 42;
18875
18874
 
18876
18875
  var useHandleTilePress = function (ctaLink, ctaLinkTarget) {
@@ -19559,7 +19558,8 @@ var useBannerTileStyles = function () {
19559
19558
  position: 'relative',
19560
19559
  overflow: 'hidden',
19561
19560
  marginRight: useResponsiveValue(theme.sizes.xxl, theme.sizes.xxs, isDesktop, isTablet),
19562
- height: 320
19561
+ maxHeight: useResponsiveValue(253, 120, isDesktop, isTablet),
19562
+ minHeight: 120
19563
19563
  },
19564
19564
  media: {
19565
19565
  position: 'absolute',
@@ -19728,6 +19728,39 @@ exports.SectionType = void 0;
19728
19728
  SectionType["Banner"] = "BANNER";
19729
19729
  })(exports.SectionType || (exports.SectionType = {}));
19730
19730
 
19731
+ /**
19732
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
19733
+ *
19734
+ * This source code is licensed under the MIT license found in the
19735
+ * LICENSE file in the root directory of this source tree.
19736
+ *
19737
+ * @format
19738
+ *
19739
+ */
19740
+
19741
+ function useWindowDimensions() {
19742
+ var _useState = React$1.useState(() => Dimensions.get('window')),
19743
+ dims = _useState[0],
19744
+ setDims = _useState[1];
19745
+ React$1.useEffect(() => {
19746
+ function handleChange(_ref) {
19747
+ var window = _ref.window;
19748
+ if (window != null) {
19749
+ setDims(window);
19750
+ }
19751
+ }
19752
+ Dimensions.addEventListener('change', handleChange);
19753
+ // We might have missed an update between calling `get` in render and
19754
+ // `addEventListener` in this handler, so we set it here. If there was
19755
+ // no change, React will filter out this update as a no-op.
19756
+ setDims(Dimensions.get('window'));
19757
+ return () => {
19758
+ Dimensions.removeEventListener('change', handleChange);
19759
+ };
19760
+ }, []);
19761
+ return dims;
19762
+ }
19763
+
19731
19764
  var useSectionHeaderStyles = function () {
19732
19765
  var _a = useResponsive$1(),
19733
19766
  isDesktop = _a.isDesktop,
@@ -19772,7 +19805,7 @@ var SectionHeader = function (_a) {
19772
19805
  }, description));
19773
19806
  };
19774
19807
 
19775
- var useCarouselStyles = function (buttonSize, slideWidth) {
19808
+ var useCarouselStyles = function (buttonSize) {
19776
19809
  if (buttonSize === void 0) {
19777
19810
  buttonSize = 42;
19778
19811
  }
@@ -19782,8 +19815,8 @@ var useCarouselStyles = function (buttonSize, slideWidth) {
19782
19815
  var theme = useWllSdk().theme;
19783
19816
  return StyleSheet$1.create({
19784
19817
  container: {
19785
- flex: 1,
19786
- maxWidth: MAX_WIDTH
19818
+ width: '100%',
19819
+ flex: 1
19787
19820
  },
19788
19821
  sectionTitle: {
19789
19822
  fontSize: 31,
@@ -19799,13 +19832,18 @@ var useCarouselStyles = function (buttonSize, slideWidth) {
19799
19832
  marginBottom: 20
19800
19833
  },
19801
19834
  carouselContainer: {
19835
+ width: '100%',
19802
19836
  flexDirection: 'row',
19803
19837
  alignItems: 'center',
19804
- justifyContent: 'center'
19838
+ justifyContent: 'center',
19839
+ position: 'relative'
19805
19840
  },
19806
19841
  carouselContent: {
19807
- overflow: 'hidden',
19808
- width: slideWidth
19842
+ width: '100%',
19843
+ overflow: 'hidden'
19844
+ },
19845
+ slideContainer: {
19846
+ width: '100%'
19809
19847
  },
19810
19848
  navButton: {
19811
19849
  position: 'absolute',
@@ -19828,9 +19866,6 @@ var useCarouselStyles = function (buttonSize, slideWidth) {
19828
19866
  right: -buttonSize / 2,
19829
19867
  backgroundColor: theme.surface
19830
19868
  },
19831
- slideContainer: {
19832
- width: slideWidth
19833
- },
19834
19869
  indicators: {
19835
19870
  flexDirection: 'row',
19836
19871
  justifyContent: 'center',
@@ -19851,36 +19886,41 @@ var useCarouselStyles = function (buttonSize, slideWidth) {
19851
19886
 
19852
19887
  var Carousel = function (_a) {
19853
19888
  var section = _a.section;
19854
- var styles = useCarouselStyles(BUTTON_SIZE, SLIDE_WIDTH);
19889
+ var windowWidth = useWindowDimensions().width;
19890
+ var containerRef = React$1.useRef(null);
19891
+ var _b = React$1.useState(windowWidth),
19892
+ containerWidth = _b[0],
19893
+ setContainerWidth = _b[1];
19894
+ var styles = useCarouselStyles(BUTTON_SIZE);
19855
19895
  var animatedIndex = React$1.useRef(new Animated$1.Value(0)).current;
19856
19896
  var theme = useWllSdk().theme;
19857
- var _b = useResponsive(),
19858
- isDesktop = _b.isDesktop,
19859
- isTablet = _b.isTablet;
19897
+ var _c = useResponsive(),
19898
+ isDesktop = _c.isDesktop,
19899
+ isTablet = _c.isTablet;
19860
19900
  var scrollViewRef = React$1.useRef(null);
19861
- var _c = React$1.useState(0),
19862
- currentIndex = _c[0],
19863
- setCurrentIndex = _c[1];
19901
+ var _d = React$1.useState(0),
19902
+ currentIndex = _d[0],
19903
+ setCurrentIndex = _d[1];
19864
19904
  var bannerTiles = section.tiles.filter(function (tile) {
19865
19905
  return tile.type === exports.TileType.Banner;
19866
19906
  });
19867
19907
  var sortedTiles = sortByPriority(bannerTiles);
19868
19908
  var handleScroll = React$1.useCallback(function (event) {
19869
19909
  var contentOffsetX = event.nativeEvent.contentOffset.x;
19870
- var newIndex = contentOffsetX / SLIDE_WIDTH;
19910
+ var newIndex = contentOffsetX / containerWidth;
19871
19911
  animatedIndex.setValue(newIndex);
19872
- }, [SLIDE_WIDTH, animatedIndex]);
19912
+ }, [containerWidth, animatedIndex]);
19873
19913
  var handleScrollEnd = React$1.useCallback(function (event) {
19874
19914
  var contentOffsetX = event.nativeEvent.contentOffset.x;
19875
- var newIndex = Math.round(contentOffsetX / SLIDE_WIDTH);
19915
+ var newIndex = Math.round(contentOffsetX / containerWidth);
19876
19916
  setCurrentIndex(newIndex);
19877
- }, [SLIDE_WIDTH]);
19917
+ }, [containerWidth]);
19878
19918
  var handlePrev = function () {
19879
19919
  var _a;
19880
19920
  var newIndex = Math.max(0, currentIndex - 1);
19881
19921
  setCurrentIndex(newIndex);
19882
19922
  (_a = scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({
19883
- x: newIndex * SLIDE_WIDTH,
19923
+ x: newIndex * containerWidth,
19884
19924
  animated: true
19885
19925
  });
19886
19926
  };
@@ -19889,7 +19929,7 @@ var Carousel = function (_a) {
19889
19929
  var newIndex = Math.min(sortedTiles.length - 1, currentIndex + 1);
19890
19930
  setCurrentIndex(newIndex);
19891
19931
  (_a = scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({
19892
- x: newIndex * SLIDE_WIDTH,
19932
+ x: newIndex * containerWidth,
19893
19933
  animated: true
19894
19934
  });
19895
19935
  };
@@ -19905,7 +19945,12 @@ var Carousel = function (_a) {
19905
19945
  title: section.title,
19906
19946
  description: section.description
19907
19947
  }), /*#__PURE__*/React$1.createElement(View$2, {
19908
- style: styles.container
19948
+ ref: containerRef,
19949
+ style: styles.container,
19950
+ onLayout: function (event) {
19951
+ var width = event.nativeEvent.layout.width;
19952
+ setContainerWidth(width);
19953
+ }
19909
19954
  }, /*#__PURE__*/React$1.createElement(View$2, {
19910
19955
  style: styles.carouselContainer
19911
19956
  }, displayControls && /*#__PURE__*/React$1.createElement(TouchableOpacity$1, {
@@ -19925,20 +19970,18 @@ var Carousel = function (_a) {
19925
19970
  onScroll: handleScroll,
19926
19971
  onMomentumScrollEnd: handleScrollEnd,
19927
19972
  scrollEventThrottle: 16,
19928
- style: [styles.carouselContent, {
19929
- width: SLIDE_WIDTH
19930
- }],
19973
+ style: [styles.carouselContent],
19931
19974
  contentContainerStyle: {
19932
- width: SLIDE_WIDTH * sortedTiles.length
19975
+ width: containerWidth * sortedTiles.length
19933
19976
  },
19934
19977
  decelerationRate: "fast",
19935
- snapToInterval: SLIDE_WIDTH,
19978
+ snapToInterval: containerWidth,
19936
19979
  snapToAlignment: "start"
19937
19980
  }, sortedTiles.map(function (tile, index) {
19938
19981
  return /*#__PURE__*/React$1.createElement(View$2, {
19939
19982
  key: index,
19940
- style: [{
19941
- width: SLIDE_WIDTH
19983
+ style: [styles.slideContainer, {
19984
+ width: containerWidth
19942
19985
  }]
19943
19986
  }, /*#__PURE__*/React$1.createElement(BannerTile, {
19944
19987
  tile: tile