@croct/plug-react 0.2.1 → 0.3.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/README.md CHANGED
@@ -64,7 +64,6 @@ We suggest putting the `<CroctProvider/ >` somewhere high in your app, above any
64
64
  ideally in the top-level `<App/>` component.
65
65
 
66
66
  ```tsx
67
- import React from 'react';
68
67
  import {render} from 'react-dom';
69
68
  import {CroctProvider} from '@croct/plug-react';
70
69
 
@@ -97,7 +96,7 @@ and a render function, which tells the component how to render the UI, depending
97
96
  This is what our component would look like:
98
97
 
99
98
  ```tsx
100
- import {ReactElement, Fragment} from 'react';
99
+ import {ReactElement, Suspense} from 'react';
101
100
  import {Personalization} from '@croct/plug-react';
102
101
 
103
102
  function OnboardingPage(): ReactElement {
@@ -117,7 +116,7 @@ function OnboardingPage(): ReactElement {
117
116
  If you don't want your component to suspend while loading, you can provide an `initial` state to be rendered instead:
118
117
 
119
118
  ```tsx
120
- import {ReactElement, Fragment} from 'react';
119
+ import {ReactElement} from 'react';
121
120
  import {Personalization} from '@croct/plug-react';
122
121
 
123
122
  function OnboardingPage(): ReactElement {
@@ -135,7 +134,7 @@ function OnboardingPage(): ReactElement {
135
134
  Now, let's create a `ViewDocsLink` component to see the `useEvaluation` hook in action:
136
135
 
137
136
  ```tsx
138
- import {ReactElement, Fragment} from 'react';
137
+ import {ReactElement, Suspense} from 'react';
139
138
  import {useEvaluation} from '@croct/plug-react';
140
139
 
141
140
  function ViewDocsLink(): ReactElement {
@@ -170,7 +169,7 @@ the personalization. In this way, the UI will still be fully functional even in
170
169
  The following example shows how you can specify a fallback behaviour for the docs link:
171
170
 
172
171
  ```tsx
173
- import {ReactElement} from 'react';
172
+ import {ReactElement, Fragment, Suspense} from 'react';
174
173
  import {Personalization, useEvaluation} from '@croct/plug-react';
175
174
 
176
175
  function ViewDocsLink(): ReactElement {
@@ -233,7 +232,7 @@ To render the content of the slot, you can either use the `<Slot />` component o
233
232
  Here's how to use the `<Slot />` component:
234
233
 
235
234
  ```tsx
236
- import {Suspense, ReactElement} from 'react';
235
+ import {ReactElement, Suspense} from 'react';
237
236
  import {Slot} from '@croct/plug-react';
238
237
 
239
238
  export default function OnboardingPage(): ReactElement {
@@ -253,10 +252,10 @@ export default function OnboardingPage(): ReactElement {
253
252
  }
254
253
  ```
255
254
 
256
- To avoid the component to suspend while loading you can provide an `initial` state to be rendered instead:
255
+ To avoid the component from suspending while loading, you can provide an `initial` state to be rendered instead:
257
256
 
258
257
  ```tsx
259
- import {Suspense, ReactElement} from 'react';
258
+ import {ReactElement} from 'react';
260
259
  import {Slot} from '@croct/plug-react';
261
260
 
262
261
  export default function OnboardingPage(): ReactElement {
@@ -281,7 +280,7 @@ export default function OnboardingPage(): ReactElement {
281
280
  And here's an example using the `useContent` hook:
282
281
 
283
282
  ```tsx
284
- import {ReactElement} from 'react';
283
+ import {ReactElement, Suspense} from 'react';
285
284
  import {useContent} from '@croct/plug-react';
286
285
 
287
286
  function HomeBanner(): ReactElement {
@@ -310,7 +309,7 @@ export default function HomePage(): ReactElement {
310
309
  The following example shows how you can specify a fallback state for the `home-banner` slot:
311
310
 
312
311
  ```tsx
313
- import {Suspense, ReactElement} from 'react';
312
+ import {ReactElement, Suspense} from 'react';
314
313
  import {Slot, useContent} from '@croct/plug-react';
315
314
 
316
315
  const fallbackBanner: HomeBanner = {
@@ -487,7 +486,7 @@ The component takes the followings properties:
487
486
  Here's a simple example showing how to evaluate the user's persona:
488
487
 
489
488
  ```tsx
490
- import {ReactElement, Fragment} from 'react';
489
+ import {ReactElement} from 'react';
491
490
  import {Personalization} from '@croct/plug-react';
492
491
 
493
492
  function PersonaBadge(): ReactElement {
@@ -521,7 +520,7 @@ The component takes the followings properties:
521
520
  Here's a simple example showing how to render a banner in a slot:
522
521
 
523
522
  ```tsx
524
- import {ReactElement, Fragment} from 'react';
523
+ import {ReactElement} from 'react';
525
524
  import {Slot} from '@croct/plug-react';
526
525
 
527
526
  function HeroBanner(): ReactElement {
@@ -597,7 +596,7 @@ These are the currently supported options:
597
596
  Here's a simple example showing how to evaluate the user's persona:
598
597
 
599
598
  ```tsx
600
- import {ReactElement, Fragment} from 'react';
599
+ import {ReactElement} from 'react';
601
600
  import {useEvaluation} from '@croct/plug-react';
602
601
 
603
602
  function PersonaBadge(): ReactElement {
@@ -632,7 +631,7 @@ These are the currently supported options:
632
631
  Here's a simple example showing how to fetch the content for a banner:
633
632
 
634
633
  ```tsx
635
- import {ReactElement, Fragment} from 'react';
634
+ import {ReactElement} from 'react';
636
635
  import {useContent} from '@croct/plug-react';
637
636
 
638
637
  function HeroBanner(): ReactElement {
package/index.js CHANGED
@@ -171,7 +171,7 @@ function useLoader(_ref) {
171
171
  try {
172
172
  setValue(cache.load(options));
173
173
  } catch (result) {
174
- if (!(result instanceof Promise)) {
174
+ if (typeof (result == null ? void 0 : result.then) !== 'function') {
175
175
  setValue(undefined);
176
176
  return;
177
177
  }
package/index.modern.js CHANGED
@@ -167,7 +167,7 @@ function useLoader(_ref) {
167
167
  try {
168
168
  setValue(cache.load(options));
169
169
  } catch (result) {
170
- if (!(result instanceof Promise)) {
170
+ if (typeof (result == null ? void 0 : result.then) !== 'function') {
171
171
  setValue(undefined);
172
172
  return;
173
173
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@croct/plug-react",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "React components and hooks to plug your React applications into Croct.",
5
5
  "author": {
6
6
  "name": "Croct",
@@ -34,11 +34,11 @@
34
34
  "build-storybook": "build-storybook -s ./.storybook/static"
35
35
  },
36
36
  "peerDependencies": {
37
- "react": "^16.8.0 || ^17.0.0",
38
- "react-dom": "^16.8.0 || ^17.0.0"
37
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
38
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
39
39
  },
40
40
  "dependencies": {
41
- "@croct/plug": "^0.8.2"
41
+ "@croct/plug": "^0.9.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@babel/core": "^7.13.13",
@@ -46,9 +46,9 @@
46
46
  "@babel/preset-react": "^7.13.13",
47
47
  "@babel/preset-typescript": "^7.13.0",
48
48
  "@storybook/addon-actions": "^6.2.3",
49
- "@storybook/addon-essentials": "^6.2.3",
49
+ "@storybook/addon-essentials": "^6.4.13",
50
50
  "@storybook/addon-links": "^6.2.3",
51
- "@storybook/react": "^6.2.3",
51
+ "@storybook/react": "^6.4.13",
52
52
  "@testing-library/jest-dom": "^5.12.0",
53
53
  "@testing-library/react": "^11.2.7",
54
54
  "@testing-library/react-hooks": "^7.0.0",
@@ -73,12 +73,12 @@
73
73
  "eslint-plugin-standard": "^5.0.0",
74
74
  "jest": "26.6.0",
75
75
  "jest-environment-node": "^26.6.2",
76
- "microbundle": "^0.13.0",
76
+ "microbundle": "^0.13.3",
77
77
  "react": "^16.0.0",
78
78
  "react-dom": "^16.0.0",
79
79
  "ts-node": "^10.0.0",
80
80
  "typescript": "^4.1.5",
81
- "webpack": "4.44.2"
81
+ "webpack": "^5.39.1"
82
82
  },
83
83
  "files": [
84
84
  "**/*.js",