@release0/react 1.0.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 ADDED
@@ -0,0 +1,144 @@
1
+ ## Install
2
+
3
+ ```bash
4
+ npm install @release0/react
5
+ ```
6
+
7
+ ## Standard
8
+
9
+ ```tsx
10
+ import { Standard } from "@release0/react";
11
+
12
+ const App = () => {
13
+ return (
14
+ <Standard
15
+ agent="my-feedback-agent"
16
+ style={{ width: "100%", height: "500px" }}
17
+ />
18
+ );
19
+ };
20
+ ```
21
+
22
+ This code is creating a container with a 100% width (will match parent width) and 500px height.
23
+
24
+ ## Popup
25
+
26
+ ```tsx
27
+ import { Popup } from "@release0/react";
28
+
29
+ const App = () => {
30
+ return <Popup agent="my-feedback-agent" autoShowDelay={2000} />;
31
+ };
32
+ ```
33
+
34
+ This code will automatically trigger the popup window after 2 seconds.
35
+
36
+ ### Open or Close a popup
37
+
38
+ You can use these commands:
39
+
40
+ ```js
41
+ import { open } from "@release0/react";
42
+
43
+ open();
44
+ ```
45
+
46
+ ```js
47
+ import { close } from "@release0/react";
48
+
49
+ close();
50
+ ```
51
+
52
+ ```js
53
+ import { toggle } from "@release0/react";
54
+
55
+ toggle();
56
+ ```
57
+
58
+ ## Bubble
59
+
60
+ ```tsx
61
+ import { Bubble } from "@release0/react";
62
+
63
+ const App = () => {
64
+ return (
65
+ <Bubble
66
+ agent="my-feedback-agent"
67
+ previewMessage={{
68
+ message: "I have a question for you!",
69
+ autoShowDelay: 5000,
70
+ avatarUrl: "https://release0.com/images/logo512.png",
71
+ }}
72
+ theme={{
73
+ button: { backgroundColor: "#0042DA", iconColor: "#FFFFFF" },
74
+ previewMessage: { backgroundColor: "#ffffff", textColor: "black" },
75
+ }}
76
+ />
77
+ );
78
+ };
79
+ ```
80
+
81
+ This code will show the bubble and let a preview message appear after 5 seconds.
82
+
83
+ ### Open or close the preview message
84
+
85
+ You can use these commands:
86
+
87
+ ```js
88
+ import { showPreviewMessage } from "@release0/react";
89
+
90
+ Agent.showPreviewMessage();
91
+ ```
92
+
93
+ ```js
94
+ import { hidePreviewMessage } from "@release0/react";
95
+
96
+ Agent.hidePreviewMessage();
97
+ ```
98
+
99
+ ### Open or close the chat window
100
+
101
+ You can use these commands:
102
+
103
+ ```js
104
+ import { open } from "@release0/react";
105
+
106
+ open();
107
+ ```
108
+
109
+ ```js
110
+ import { close } from "@release0/react";
111
+
112
+ close();
113
+ ```
114
+
115
+ ```js
116
+ import { toggle } from "@release0/react";
117
+
118
+ toggle();
119
+ ```
120
+
121
+ ## Additional configuration
122
+
123
+ You can prefill the agent variable values in your embed code by adding the `prefilledVariables` option. Here is an example:
124
+
125
+ ```tsx
126
+ import { Standard } from "@release0/react";
127
+
128
+ const App = () => {
129
+ return (
130
+ <Standard
131
+ agent="my-feedback-agent"
132
+ style={{ width: "100%", height: "600px" }}
133
+ prefilledVariables={{
134
+ "Account URL": "https://my-site.com/account",
135
+ "User name": "My Username",
136
+ }}
137
+ />
138
+ );
139
+ };
140
+ ```
141
+
142
+ It will prefill the `Account URL` variable with "https://my-site.com/account" and the `User name` variable with "My Username".
143
+
144
+ Note that if your site URL contains query params (i.e. https://my-site.com/account?User%20name=My%20Username), the variables will automatically be injected to the agent. So you don't need to manually transfer query params to the agent embed configuration.
@@ -0,0 +1,43 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { AgentProps, BubbleProps, PopupProps } from '@release0/js';
3
+ export * from '@release0/js';
4
+ import React from 'react';
5
+
6
+ type Props$2 = AgentProps & {
7
+ style?: React.CSSProperties;
8
+ className?: string;
9
+ };
10
+ declare global {
11
+ namespace JSX {
12
+ interface IntrinsicElements {
13
+ "agent-standard": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
14
+ class?: string;
15
+ };
16
+ }
17
+ }
18
+ }
19
+ declare const Standard: ({ style, className, ...assignableProps }: Props$2) => react_jsx_runtime.JSX.Element;
20
+
21
+ type Props$1 = BubbleProps;
22
+ declare global {
23
+ namespace JSX {
24
+ interface IntrinsicElements {
25
+ "agent-bubble": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
26
+ }
27
+ }
28
+ }
29
+ declare const Bubble: (props: Props$1) => react_jsx_runtime.JSX.Element | null;
30
+
31
+ type Props = PopupProps;
32
+ declare global {
33
+ namespace JSX {
34
+ interface IntrinsicElements {
35
+ "agent-popup": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
36
+ class?: string;
37
+ };
38
+ }
39
+ }
40
+ }
41
+ declare const Popup: (props: Props) => react_jsx_runtime.JSX.Element;
42
+
43
+ export { Bubble, Popup, Standard };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{useEffect as m,useRef as i}from"react";import"@release0/js/web";import{jsx as b}from"react/jsx-runtime";var f=({style:r,className:e,...t})=>{let n=i(null);return m(()=>{if(!n.current||typeof t!="object"||t===null)return;let{children:p,ref:o,key:l,...a}=t;Object.assign(n.current,a)},[t]),b("agent-standard",{ref:n,style:r,class:e})};import{useEffect as c,useRef as d}from"react";import"@release0/js/web";import{jsx as P}from"react/jsx-runtime";var E=r=>{let e=d(null);return c(()=>{if(r.theme?.position==="static"&&!e.current)return;e.current||(e.current=document.createElement("agent-bubble"),document.body.prepend(e.current));let{agent:t,...n}=r;Object.assign(e.current,n,{agent:t})},[r]),c(()=>()=>{r.theme?.position!=="static"&&(e.current?.remove(),e.current=null)},[r.theme?.position]),r.theme?.position==="static"?P("agent-bubble",{ref:e,style:{display:"inline-flex"}}):null};import{useCallback as y,useEffect as u,useRef as s}from"react";import"@release0/js/web";import{jsx as g}from"react/jsx-runtime";var T=r=>{let e=s(null),t=s(null),n=y(o=>{let l=document.createElement("agent-popup");if(t.current=l,p(t.current,o),!e.current){console.warn("Could not attach popup to container because containerRef.current is null");return}e.current?.append(t.current)},[]);u(()=>{t.current||n(r),p(t.current,r)},[n,r]),u(()=>()=>{t.current?.remove(),t.current=null},[]);let p=(o,l)=>{Object.assign(o,l)};return g("div",{ref:e})};export*from"@release0/js";export{E as Bubble,T as Popup,f as Standard};
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@release0/react",
3
+ "version": "1.0.0",
4
+ "description": "Library to display Release0 agents on your React app",
5
+ "license": "FSL-1.1-ALv2",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "dev": "tsup --watch",
17
+ "build": "tsup"
18
+ },
19
+ "dependencies": {
20
+ "react": "18.2.15",
21
+ "@release0/js": "1.1.4"
22
+ },
23
+ "devDependencies": {
24
+ "@release0/tsconfig": "0.0.1",
25
+ "@types/react": "18.2.15",
26
+ "tsup": "8.3.0",
27
+ "react": "18.2.0"
28
+ },
29
+ "peerDependencies": {
30
+ "react": "^16.0.0 || ^17.0.0 || ^18.0.0",
31
+ "@release0/js": "^1.1.4 || workspace:*"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ }
36
+ }