@release0/react 1.0.3 → 1.1.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
@@ -120,7 +120,7 @@ toggle();
120
120
 
121
121
  ## Additional configuration
122
122
 
123
- You can prefill the agent variable values in your embed code by adding the `prefilledVariables` option. Here is an example:
123
+ You can prefill the agent variable values in your embed code by adding the `initialContext` option. Here is an example:
124
124
 
125
125
  ```tsx
126
126
  import { Standard } from "@release0/react";
@@ -130,7 +130,7 @@ const App = () => {
130
130
  <Standard
131
131
  agent="ag_herexisxyourxagentxid"
132
132
  style={{ width: "100%", height: "600px" }}
133
- prefilledVariables={{
133
+ initialContext={{
134
134
  "Account URL": "https://my-site.com/account",
135
135
  "User name": "My Username",
136
136
  }}
package/dist/index.d.ts CHANGED
@@ -1,43 +1,43 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { AgentProps, BubbleProps, PopupProps } from '@release0/js';
1
+ import { BubbleProps, PopupProps, AgentProps } from '@release0/js';
3
2
  export * from '@release0/js';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import React from 'react';
5
5
 
6
- type Props$2 = AgentProps & {
7
- style?: React.CSSProperties;
8
- className?: string;
9
- };
6
+ type Props$2 = BubbleProps;
10
7
  declare global {
11
- namespace JSX {
8
+ namespace React.JSX {
12
9
  interface IntrinsicElements {
13
- "agent-standard": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
14
- class?: string;
15
- };
10
+ "agent-bubble": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
16
11
  }
17
12
  }
18
13
  }
19
- declare const Standard: ({ style, className, ...assignableProps }: Props$2) => react_jsx_runtime.JSX.Element;
14
+ declare const Bubble: (props: Props$2) => react_jsx_runtime.JSX.Element | null;
20
15
 
21
- type Props$1 = BubbleProps;
16
+ type Props$1 = PopupProps;
22
17
  declare global {
23
- namespace JSX {
18
+ namespace React.JSX {
24
19
  interface IntrinsicElements {
25
- "agent-bubble": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
20
+ "agent-popup": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
21
+ class?: string;
22
+ };
26
23
  }
27
24
  }
28
25
  }
29
- declare const Bubble: (props: Props$1) => react_jsx_runtime.JSX.Element | null;
26
+ declare const Popup: (props: Props$1) => react_jsx_runtime.JSX.Element;
30
27
 
31
- type Props = PopupProps;
28
+ type Props = AgentProps & {
29
+ style?: React.CSSProperties;
30
+ className?: string;
31
+ };
32
32
  declare global {
33
- namespace JSX {
33
+ namespace React.JSX {
34
34
  interface IntrinsicElements {
35
- "agent-popup": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
35
+ "agent-standard": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
36
36
  class?: string;
37
37
  };
38
38
  }
39
39
  }
40
40
  }
41
- declare const Popup: (props: Props) => react_jsx_runtime.JSX.Element;
41
+ declare const Standard: ({ style, className, ...assignableProps }: Props) => react_jsx_runtime.JSX.Element;
42
42
 
43
43
  export { Bubble, Popup, Standard };
package/dist/index.js CHANGED
@@ -1 +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};
1
+ var w=({id:t}={})=>{let e={isFromAgent:!0,command:"close",id:t};window.postMessage(e)},v=({id:t}={})=>{let e={isFromAgent:!0,command:"open",id:t};window.postMessage(e)},R=(t,{id:e}={})=>{let n={isFromAgent:!0,command:"showPreviewMessage",message:t,id:e};window.postMessage(n)},T=({id:t}={})=>{let e={isFromAgent:!0,command:"toggle",id:t};window.postMessage(e)},H=({id:t}={})=>{let e={isFromAgent:!0,command:"reload",id:t};window.postMessage(e)},L=(t,{id:e}={})=>{let n={isFromAgent:!0,command:"setInputValue",value:t,id:e};window.postMessage(n)},y=({id:t}={})=>{let e={isFromAgent:!0,command:"unmount",id:t};window.postMessage(e)},A=(t,{id:e}={})=>{let n={isFromAgent:!0,command:"setPrefilledVariables",variables:t,id:e};window.postMessage(n)},h=({id:t}={})=>{let e={isFromAgent:!0,command:"hidePreviewMessage",id:t};window.postMessage(e)};import{useEffect as l,useRef as c}from"react";import{jsx as u}from"react/jsx-runtime";var m=t=>{let e=c(null);return l(()=>{t.theme?.position!=="static"&&(e.current||(e.current=document.createElement("agent-bubble"),document.body.prepend(e.current)),import("./web-53BLTPE3.js").then(()=>{let{agent:n,...r}=t;Object.assign(e.current??document.createElement("agent-bubble"),r,{agent:n})}))},[t]),l(()=>()=>{t.theme?.position!=="static"&&(e.current?.remove(),e.current=null)},[t.theme?.position]),t.theme?.position==="static"?u("agent-bubble",{ref:e,style:{display:"inline-flex"}}):null};import{useCallback as d,useEffect as i,useRef as p}from"react";import{jsx as f}from"react/jsx-runtime";var g=t=>{let e=p(null),n=p(null),r=d(s=>{let a=document.createElement("agent-popup");if(n.current=a,o(n.current,s),!e.current){console.warn("Could not attach popup to container because containerRef.current is null");return}e.current?.append(n.current)},[]);i(()=>{n.current||r(t),o(n.current,t)},[r,t]),i(()=>()=>{n.current?.remove(),n.current=null},[]);let o=(s,a)=>{import("./web-53BLTPE3.js").then(()=>{Object.assign(s,a)})};return f("div",{ref:e})};import{useEffect as b,useRef as P}from"react";import{jsx as M}from"react/jsx-runtime";var E=({style:t,className:e,...n})=>{let r=P(null);return b(()=>{import("./web-53BLTPE3.js").then(()=>{let{agent:o,...s}=n;Object.assign(r.current,s,{agent:o})})},[n]),M("agent-standard",{ref:r,style:t,class:e})};export{m as Bubble,g as Popup,E as Standard,w as close,h as hidePreviewMessage,v as open,H as reload,L as setInputValue,A as setPrefilledVariables,R as showPreviewMessage,T as toggle,y as unmount};