@ninetailed/experience.js-react 4.0.0-beta.8 → 4.1.0-beta.0

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/index.cjs CHANGED
@@ -2501,6 +2501,29 @@ const ComponentWrapper = _a => {
2501
2501
  });
2502
2502
  };
2503
2503
 
2504
+ /**
2505
+ * This component is used to conditionally render Experiences which may include empty variants.
2506
+ * It is essential to intercept the props within the ComponentWrapper to be able to get the current variant.
2507
+ * Note: the passed props can be altered by the render plugins.
2508
+ */
2509
+ const ConditionalRenderComponent = _a => {
2510
+ var {
2511
+ children
2512
+ } = _a,
2513
+ props = __rest(_a, ["children"]);
2514
+ if ('hidden' in props && props.hidden) {
2515
+ return null;
2516
+ }
2517
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
2518
+ children: React__default["default"].Children.map(children, child => {
2519
+ if ( /*#__PURE__*/React__default["default"].isValidElement(child)) {
2520
+ return /*#__PURE__*/React__default["default"].cloneElement(child, props);
2521
+ }
2522
+ return null;
2523
+ })
2524
+ });
2525
+ };
2526
+
2504
2527
  const DefaultExperienceLoadingComponent = _a => {
2505
2528
  var {
2506
2529
  component: Component,
@@ -2633,19 +2656,21 @@ const Experience = _a => {
2633
2656
  // the profile is definitely defined, otherwise there wouldn't be an experience selected
2634
2657
  profile: profile
2635
2658
  }, {
2636
- children: 'hidden' in variant && variant.hidden ? null : jsxRuntime.jsx(ComponentWrapper, Object.assign({
2659
+ children: jsxRuntime.jsx(ComponentWrapper, Object.assign({
2637
2660
  experiences: experiences,
2638
2661
  baseline: baseline
2639
2662
  }, {
2640
- children: /*#__PURE__*/React.createElement(Component, Object.assign({}, Object.assign(Object.assign({}, passthroughProps), variant), {
2641
- key: `${experience.id}-${variant.id}`,
2642
- ninetailed: {
2643
- isPersonalized,
2644
- audience: {
2645
- id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
2663
+ children: jsxRuntime.jsx(ConditionalRenderComponent, {
2664
+ children: /*#__PURE__*/React.createElement(Component, Object.assign({}, Object.assign(Object.assign({}, passthroughProps), variant), {
2665
+ key: `${experience.id}-${variant.id}`,
2666
+ ninetailed: {
2667
+ isPersonalized,
2668
+ audience: {
2669
+ id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
2670
+ }
2646
2671
  }
2647
- }
2648
- }))
2672
+ }))
2673
+ })
2649
2674
  }))
2650
2675
  }));
2651
2676
  };
package/index.js CHANGED
@@ -2488,6 +2488,29 @@ const ComponentWrapper = _a => {
2488
2488
  });
2489
2489
  };
2490
2490
 
2491
+ /**
2492
+ * This component is used to conditionally render Experiences which may include empty variants.
2493
+ * It is essential to intercept the props within the ComponentWrapper to be able to get the current variant.
2494
+ * Note: the passed props can be altered by the render plugins.
2495
+ */
2496
+ const ConditionalRenderComponent = _a => {
2497
+ var {
2498
+ children
2499
+ } = _a,
2500
+ props = __rest(_a, ["children"]);
2501
+ if ('hidden' in props && props.hidden) {
2502
+ return null;
2503
+ }
2504
+ return jsx(Fragment, {
2505
+ children: React.Children.map(children, child => {
2506
+ if ( /*#__PURE__*/React.isValidElement(child)) {
2507
+ return /*#__PURE__*/React.cloneElement(child, props);
2508
+ }
2509
+ return null;
2510
+ })
2511
+ });
2512
+ };
2513
+
2491
2514
  const DefaultExperienceLoadingComponent = _a => {
2492
2515
  var {
2493
2516
  component: Component,
@@ -2620,19 +2643,21 @@ const Experience = _a => {
2620
2643
  // the profile is definitely defined, otherwise there wouldn't be an experience selected
2621
2644
  profile: profile
2622
2645
  }, {
2623
- children: 'hidden' in variant && variant.hidden ? null : jsx(ComponentWrapper, Object.assign({
2646
+ children: jsx(ComponentWrapper, Object.assign({
2624
2647
  experiences: experiences,
2625
2648
  baseline: baseline
2626
2649
  }, {
2627
- children: /*#__PURE__*/createElement$1(Component, Object.assign({}, Object.assign(Object.assign({}, passthroughProps), variant), {
2628
- key: `${experience.id}-${variant.id}`,
2629
- ninetailed: {
2630
- isPersonalized,
2631
- audience: {
2632
- id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
2650
+ children: jsx(ConditionalRenderComponent, {
2651
+ children: /*#__PURE__*/createElement$1(Component, Object.assign({}, Object.assign(Object.assign({}, passthroughProps), variant), {
2652
+ key: `${experience.id}-${variant.id}`,
2653
+ ninetailed: {
2654
+ isPersonalized,
2655
+ audience: {
2656
+ id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
2657
+ }
2633
2658
  }
2634
- }
2635
- }))
2659
+ }))
2660
+ })
2636
2661
  }))
2637
2662
  }));
2638
2663
  };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ /**
3
+ * This component is used to conditionally render Experiences which may include empty variants.
4
+ * It is essential to intercept the props within the ComponentWrapper to be able to get the current variant.
5
+ * Note: the passed props can be altered by the render plugins.
6
+ */
7
+ export declare const ConditionalRenderComponent: React.FC<React.PropsWithChildren>;
@@ -1,6 +1,6 @@
1
1
  import { FC, PropsWithChildren } from 'react';
2
2
  import { Baseline, ExperienceConfiguration } from '@ninetailed/experience.js';
3
- import { Variant } from '../Experience/types/Variant';
3
+ import { Variant } from '../Experience/types';
4
4
  type ComponentRenderInterceptorWrapperProps = {
5
5
  experiences: ExperienceConfiguration<Variant<any>>[];
6
6
  baseline: Baseline;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-react",
3
- "version": "4.0.0-beta.8",
3
+ "version": "4.1.0-beta.0",
4
4
  "peerDependencies": {
5
5
  "react": ">=16.8.0"
6
6
  },
@@ -8,9 +8,9 @@
8
8
  "@analytics/google-analytics": "0.5.3",
9
9
  "react-visibility-sensor": "5.1.1",
10
10
  "lodash": "4.17.21",
11
- "@ninetailed/experience.js": "4.0.0-beta.8",
11
+ "@ninetailed/experience.js": "4.1.0-beta.0",
12
12
  "react-intersection-observer": "8.34.0",
13
- "@ninetailed/experience.js-shared": "4.0.0-beta.8",
13
+ "@ninetailed/experience.js-shared": "4.1.0-beta.0",
14
14
  "analytics": "0.8.1"
15
15
  },
16
16
  "module": "./index.js",