@folklore/ads 0.0.21 → 0.0.22

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.
Files changed (3) hide show
  1. package/dist/cjs.js +12 -4
  2. package/dist/es.js +12 -4
  3. package/package.json +2 -2
package/dist/cjs.js CHANGED
@@ -733,20 +733,28 @@ const useAdsTargeting = () => React.useContext(AdsTargetingContext);
733
733
  const propTypes$1 = {
734
734
  children: PropTypes__default["default"].node.isRequired,
735
735
  // eslint-disable-next-line react/forbid-prop-types
736
- targeting: PropTypes__default["default"].object
736
+ targeting: PropTypes__default["default"].object,
737
+ replace: PropTypes__default["default"].bool
737
738
  };
738
739
  const defaultProps$1 = {
739
740
  targeting: {
740
741
  domain: typeof window !== 'undefined' ? `${window.location.protocol}//${window.location.host}` : null
741
- }
742
+ },
743
+ replace: false
742
744
  };
743
745
  function AdsTargetingProvider(_ref) {
744
746
  let {
745
747
  children,
746
- targeting
748
+ targeting,
749
+ replace
747
750
  } = _ref;
751
+ const previousTargeting = useAdsTargeting();
752
+ const mergedTargeting = React.useMemo(() => replace ? targeting : {
753
+ ...previousTargeting,
754
+ ...targeting
755
+ }, [replace, previousTargeting, targeting]);
748
756
  return /*#__PURE__*/jsxRuntime.jsx(AdsTargetingContext.Provider, {
749
- value: targeting,
757
+ value: mergedTargeting,
750
758
  children: children
751
759
  });
752
760
  }
package/dist/es.js CHANGED
@@ -715,20 +715,28 @@ const useAdsTargeting = () => useContext(AdsTargetingContext);
715
715
  const propTypes$1 = {
716
716
  children: PropTypes.node.isRequired,
717
717
  // eslint-disable-next-line react/forbid-prop-types
718
- targeting: PropTypes.object
718
+ targeting: PropTypes.object,
719
+ replace: PropTypes.bool
719
720
  };
720
721
  const defaultProps$1 = {
721
722
  targeting: {
722
723
  domain: typeof window !== 'undefined' ? `${window.location.protocol}//${window.location.host}` : null
723
- }
724
+ },
725
+ replace: false
724
726
  };
725
727
  function AdsTargetingProvider(_ref) {
726
728
  let {
727
729
  children,
728
- targeting
730
+ targeting,
731
+ replace
729
732
  } = _ref;
733
+ const previousTargeting = useAdsTargeting();
734
+ const mergedTargeting = useMemo(() => replace ? targeting : {
735
+ ...previousTargeting,
736
+ ...targeting
737
+ }, [replace, previousTargeting, targeting]);
730
738
  return /*#__PURE__*/jsx(AdsTargetingContext.Provider, {
731
- value: targeting,
739
+ value: mergedTargeting,
732
740
  children: children
733
741
  });
734
742
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@folklore/ads",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "Ads library",
5
5
  "keywords": [
6
6
  "javascript",
@@ -50,7 +50,7 @@
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
- "gitHead": "a1fba2a5f49386559db95f06339bc64b134265b0",
53
+ "gitHead": "6582d1723398b40a05f58eb46e34589c8cbe7471",
54
54
  "dependencies": {
55
55
  "@folklore/hooks": "^0.0.42",
56
56
  "@folklore/tracking": "^0.0.16",