@ninetailed/experience.js-react 2.2.0-beta.0 → 2.2.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.esm.js CHANGED
@@ -2571,9 +2571,10 @@ const DefaultExperienceLoadingComponent = _a => {
2571
2571
  var {
2572
2572
  component: Component,
2573
2573
  experiences,
2574
- unhideAfterMs = 5000
2574
+ unhideAfterMs = 5000,
2575
+ passthroughProps
2575
2576
  } = _a,
2576
- baseline = __rest(_a, ["component", "experiences", "unhideAfterMs"]);
2577
+ baseline = __rest(_a, ["component", "experiences", "unhideAfterMs", "passthroughProps"]);
2577
2578
 
2578
2579
  const {
2579
2580
  logger
@@ -2595,7 +2596,7 @@ const DefaultExperienceLoadingComponent = _a => {
2595
2596
  style: {
2596
2597
  opacity: 0
2597
2598
  }
2598
- }, /*#__PURE__*/React.createElement(Component, Object.assign({}, baseline, {
2599
+ }, /*#__PURE__*/React.createElement(Component, Object.assign({}, passthroughProps, baseline, {
2599
2600
  ninetailed: {
2600
2601
  isPersonalized: false,
2601
2602
  audience: {
@@ -2605,7 +2606,7 @@ const DefaultExperienceLoadingComponent = _a => {
2605
2606
  })));
2606
2607
  }
2607
2608
 
2608
- return /*#__PURE__*/React.createElement(Component, Object.assign({}, baseline, {
2609
+ return /*#__PURE__*/React.createElement(Component, Object.assign({}, passthroughProps, baseline, {
2609
2610
  ninetailed: {
2610
2611
  isPersonalized: false,
2611
2612
  audience: {
@@ -2618,9 +2619,10 @@ const Experience = _a => {
2618
2619
  var {
2619
2620
  experiences,
2620
2621
  component: Component,
2621
- loadingComponent: LoadingComponent = DefaultExperienceLoadingComponent
2622
+ loadingComponent: LoadingComponent = DefaultExperienceLoadingComponent,
2623
+ passthroughProps
2622
2624
  } = _a,
2623
- baseline = __rest(_a, ["experiences", "component", "loadingComponent"]);
2625
+ baseline = __rest(_a, ["experiences", "component", "loadingComponent", "passthroughProps"]);
2624
2626
 
2625
2627
  const {
2626
2628
  status,
@@ -2647,18 +2649,19 @@ const Experience = _a => {
2647
2649
  }, [status, experience, profile]);
2648
2650
 
2649
2651
  if (!hasVariants) {
2650
- return /*#__PURE__*/React.createElement(Component, Object.assign({}, baseline));
2652
+ return /*#__PURE__*/React.createElement(Component, Object.assign({}, passthroughProps, baseline));
2651
2653
  }
2652
2654
 
2653
2655
  if (status === 'loading') {
2654
2656
  return /*#__PURE__*/React.createElement(LoadingComponent, Object.assign({}, baseline, {
2657
+ passthroughProps: passthroughProps,
2655
2658
  experiences: experiences,
2656
2659
  component: Component
2657
2660
  }));
2658
2661
  }
2659
2662
 
2660
2663
  if (!experience) {
2661
- return /*#__PURE__*/React.createElement(Component, Object.assign({}, baseline, {
2664
+ return /*#__PURE__*/React.createElement(Component, Object.assign({}, passthroughProps, baseline, {
2662
2665
  key: baseline.id,
2663
2666
  ninetailed: {
2664
2667
  isPersonalized: false,
@@ -2675,7 +2678,7 @@ const Experience = _a => {
2675
2678
  variant: baseline,
2676
2679
  // the profile is definitely defined, otherwise there wouldn't be an experience selected
2677
2680
  profile: profile
2678
- }, /*#__PURE__*/React.createElement(Component, Object.assign({}, baseline, {
2681
+ }, /*#__PURE__*/React.createElement(Component, Object.assign({}, passthroughProps, baseline, {
2679
2682
  key: baseline.id,
2680
2683
  ninetailed: {
2681
2684
  isPersonalized: false,
package/index.umd.js CHANGED
@@ -2119,7 +2119,8 @@
2119
2119
  _a.experiences;
2120
2120
  var _b = _a.unhideAfterMs,
2121
2121
  unhideAfterMs = _b === void 0 ? 5000 : _b,
2122
- baseline = __rest(_a, ["component", "experiences", "unhideAfterMs"]);
2122
+ passthroughProps = _a.passthroughProps,
2123
+ baseline = __rest(_a, ["component", "experiences", "unhideAfterMs", "passthroughProps"]);
2123
2124
 
2124
2125
  var logger = useNinetailed().logger;
2125
2126
 
@@ -2143,7 +2144,7 @@
2143
2144
  style: {
2144
2145
  opacity: 0
2145
2146
  }
2146
- }, /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, baseline, {
2147
+ }, /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, passthroughProps, baseline, {
2147
2148
  ninetailed: {
2148
2149
  isPersonalized: false,
2149
2150
  audience: {
@@ -2153,7 +2154,7 @@
2153
2154
  })));
2154
2155
  }
2155
2156
 
2156
- return /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, baseline, {
2157
+ return /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, passthroughProps, baseline, {
2157
2158
  ninetailed: {
2158
2159
  isPersonalized: false,
2159
2160
  audience: {
@@ -2167,7 +2168,8 @@
2167
2168
  Component = _a.component,
2168
2169
  _b = _a.loadingComponent,
2169
2170
  LoadingComponent = _b === void 0 ? DefaultExperienceLoadingComponent : _b,
2170
- baseline = __rest(_a, ["experiences", "component", "loadingComponent"]);
2171
+ passthroughProps = _a.passthroughProps,
2172
+ baseline = __rest(_a, ["experiences", "component", "loadingComponent", "passthroughProps"]);
2171
2173
 
2172
2174
  var _c = useExperience({
2173
2175
  baseline: baseline,
@@ -2194,18 +2196,19 @@
2194
2196
  }, [status, experience, profile]);
2195
2197
 
2196
2198
  if (!hasVariants) {
2197
- return /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, baseline));
2199
+ return /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, passthroughProps, baseline));
2198
2200
  }
2199
2201
 
2200
2202
  if (status === 'loading') {
2201
2203
  return /*#__PURE__*/React__default["default"].createElement(LoadingComponent, __assign({}, baseline, {
2204
+ passthroughProps: passthroughProps,
2202
2205
  experiences: experiences,
2203
2206
  component: Component
2204
2207
  }));
2205
2208
  }
2206
2209
 
2207
2210
  if (!experience) {
2208
- return /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, baseline, {
2211
+ return /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, passthroughProps, baseline, {
2209
2212
  key: baseline.id,
2210
2213
  ninetailed: {
2211
2214
  isPersonalized: false,
@@ -2222,7 +2225,7 @@
2222
2225
  variant: baseline,
2223
2226
  // the profile is definitely defined, otherwise there wouldn't be an experience selected
2224
2227
  profile: profile
2225
- }, /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, baseline, {
2228
+ }, /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, passthroughProps, baseline, {
2226
2229
  key: baseline.id,
2227
2230
  ninetailed: {
2228
2231
  isPersonalized: false,
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Baseline, ExperienceConfiguration } from '@ninetailed/experience.js';
3
- export declare type ExperienceComponent<P extends Baseline> = React.ComponentType<Omit<P, 'id'> & {
3
+ export declare type ExperienceComponent<P> = React.ComponentType<Omit<P, 'id'> & {
4
4
  ninetailed?: {
5
5
  isPersonalized: boolean;
6
6
  audience: {
@@ -8,21 +8,20 @@ export declare type ExperienceComponent<P extends Baseline> = React.ComponentTyp
8
8
  };
9
9
  };
10
10
  }>;
11
- export declare type ExperienceBaseProps<P extends Baseline = Baseline> = P & {
11
+ export declare type ExperienceBaseProps<P, PassThroughProps extends Partial<P>> = Baseline<Pick<P, Exclude<keyof P, keyof PassThroughProps>>> & {
12
12
  experiences: ExperienceConfiguration[];
13
13
  component: ExperienceComponent<P> | React.ComponentType<P>;
14
+ passthroughProps?: PassThroughProps;
14
15
  };
15
- export declare type ExperienceLoadingComponent<P extends Baseline = Baseline> = React.ComponentType<ExperienceBaseProps<P>>;
16
- export declare type ExperienceProps<P extends Baseline> = ExperienceBaseProps<P> & {
16
+ export declare type ExperienceLoadingComponent<P, PassThroughProps extends Partial<P>> = React.ComponentType<ExperienceBaseProps<P, PassThroughProps>>;
17
+ export declare type ExperienceProps<P, PassThroughProps extends Partial<P>> = ExperienceBaseProps<P, PassThroughProps> & {
17
18
  experiences: ExperienceConfiguration[];
18
19
  component: ExperienceComponent<P> | React.ComponentType<P>;
19
- loadingComponent?: ExperienceLoadingComponent<P>;
20
+ loadingComponent?: ExperienceLoadingComponent<P, PassThroughProps>;
20
21
  };
21
- declare type DefaultExperienceLoadingComponentProps = ExperienceBaseProps & {
22
+ declare type DefaultExperienceLoadingComponentProps = ExperienceBaseProps<{}, {}> & {
22
23
  unhideAfterMs?: number;
23
24
  };
24
25
  export declare const DefaultExperienceLoadingComponent: React.FC<DefaultExperienceLoadingComponentProps>;
25
- export declare const Experience: <P extends {
26
- id: string;
27
- }>({ experiences, component: Component, loadingComponent: LoadingComponent, ...baseline }: ExperienceProps<P>) => JSX.Element;
26
+ export declare const Experience: <P extends Object, PassThroughProps extends Partial<P> = Partial<P>>({ experiences, component: Component, loadingComponent: LoadingComponent, passthroughProps, ...baseline }: ExperienceProps<P, PassThroughProps>) => JSX.Element;
28
27
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-react",
3
- "version": "2.2.0-beta.0",
3
+ "version": "2.2.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": "2.2.0-beta.0",
11
+ "@ninetailed/experience.js": "2.2.0",
12
12
  "analytics": "^0.8.0",
13
- "@ninetailed/experience.js-shared": "2.2.0-beta.0",
13
+ "@ninetailed/experience.js-shared": "2.2.0",
14
14
  "uuid": "^8.3.2",
15
15
  "ts-toolbelt": "^9.6.0",
16
16
  "locale-enum": "^1.1.1",