@release0/nextjs 0.2.0 → 0.2.1

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
@@ -12,7 +12,7 @@ import { Standard } from "@release0/nextjs";
12
12
  const App = () => {
13
13
  return (
14
14
  <Standard
15
- agent="my-questions-agent"
15
+ agent="ag_herexisxyourxagentxid"
16
16
  style={{ width: "100%", height: "600px" }}
17
17
  />
18
18
  );
@@ -27,7 +27,7 @@ This code is creating a container with a 100% width (will match parent width) an
27
27
  import { Popup } from "@release0/nextjs";
28
28
 
29
29
  const App = () => {
30
- return <Popup agent="my-questions-agent" autoShowDelay={3000} />;
30
+ return <Popup agent="ag_herexisxyourxagentxid" autoShowDelay={3000} />;
31
31
  };
32
32
  ```
33
33
 
@@ -63,7 +63,7 @@ import { Bubble } from "@release0/nextjs";
63
63
  const App = () => {
64
64
  return (
65
65
  <Bubble
66
- agent="my-questions-agent"
66
+ agent="ag_herexisxyourxagentxid"
67
67
  previewMessage={{
68
68
  message: "I have a question for you!",
69
69
  autoShowDelay: 5000,
@@ -128,17 +128,17 @@ import { Standard } from "@release0/nextjs";
128
128
  const App = () => {
129
129
  return (
130
130
  <Standard
131
- agent="my-questions-agent"
131
+ agent="ag_herexisxyourxagentxid"
132
132
  style={{ width: "100%", height: "600px" }}
133
133
  prefilledVariables={{
134
- "Current URL": "https://my-site.com/account",
135
- "User name": "John Doe",
134
+ "Account URL": "https://my-site.com/account",
135
+ "User name": "My username",
136
136
  }}
137
137
  />
138
138
  );
139
139
  };
140
140
  ```
141
141
 
142
- It will prefill the `Current URL` variable with "https://my-site.com/account" and the `User name` variable with "John Doe".
142
+ It will prefill the `Account URL` variable with "https://my-site.com/account" and the `User name` variable with "My username".
143
143
 
144
- Note: If your site URL contains query params (i.e. https://release0?User%20name=John%20Doe), the variables will automatically be injected to the agent. So you don't need to manually transfer query params to the agent embed configuration.
144
+ Note: 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,56 @@
1
+ "use client"
2
+
3
+ // ../react/dist/index.js
4
+ import { useEffect as m, useRef as i } from "react";
5
+ import "@release0/js/web";
6
+ import { jsx as b } from "react/jsx-runtime";
7
+ import { useEffect as c, useRef as d } from "react";
8
+ import "@release0/js/web";
9
+ import { jsx as P } from "react/jsx-runtime";
10
+ import { useCallback as y, useEffect as u, useRef as s } from "react";
11
+ import "@release0/js/web";
12
+ import { jsx as g } from "react/jsx-runtime";
13
+ export * from "@release0/js";
14
+ var f = ({ style: r, className: e, ...t }) => {
15
+ let n = i(null);
16
+ return m(() => {
17
+ if (!n.current || typeof t != "object" || t === null) return;
18
+ let { children: p, ref: o, key: l, ...a } = t;
19
+ Object.assign(n.current, a);
20
+ }, [t]), b("agent-standard", { ref: n, style: r, class: e });
21
+ };
22
+ var E = (r) => {
23
+ let e = d(null);
24
+ return c(() => {
25
+ if (r.theme?.position === "static" && !e.current) return;
26
+ e.current || (e.current = document.createElement("agent-bubble"), document.body.prepend(e.current));
27
+ let { agent: t, ...n } = r;
28
+ Object.assign(e.current, n, { agent: t });
29
+ }, [r]), c(() => () => {
30
+ r.theme?.position !== "static" && (e.current?.remove(), e.current = null);
31
+ }, [r.theme?.position]), r.theme?.position === "static" ? P("agent-bubble", { ref: e, style: { display: "inline-flex" } }) : null;
32
+ };
33
+ var T = (r) => {
34
+ let e = s(null), t = s(null), n = y((o) => {
35
+ let l = document.createElement("agent-popup");
36
+ if (t.current = l, p(t.current, o), !e.current) {
37
+ console.warn("Could not attach popup to container because containerRef.current is null");
38
+ return;
39
+ }
40
+ e.current?.append(t.current);
41
+ }, []);
42
+ u(() => {
43
+ t.current || n(r), p(t.current, r);
44
+ }, [n, r]), u(() => () => {
45
+ t.current?.remove(), t.current = null;
46
+ }, []);
47
+ let p = (o, l) => {
48
+ Object.assign(o, l);
49
+ };
50
+ return g("div", { ref: e });
51
+ };
52
+ export {
53
+ E as Bubble,
54
+ T as Popup,
55
+ f as Standard
56
+ };
package/dist/index.js CHANGED
@@ -13,19 +13,19 @@ import {
13
13
  close
14
14
  } from "@release0/js";
15
15
  var Standard = dynamic(
16
- () => import("./dist-7FPSDZKC.js").then((mod) => mod.Standard),
16
+ () => import("./dist-WPLDFLQO.js").then((mod) => mod.Standard),
17
17
  {
18
18
  ssr: false
19
19
  }
20
20
  );
21
21
  var Bubble = dynamic(
22
- () => import("./dist-7FPSDZKC.js").then((mod) => mod.Bubble),
22
+ () => import("./dist-WPLDFLQO.js").then((mod) => mod.Bubble),
23
23
  {
24
24
  ssr: false
25
25
  }
26
26
  );
27
27
  var Popup = dynamic(
28
- () => import("./dist-7FPSDZKC.js").then((mod) => mod.Popup),
28
+ () => import("./dist-WPLDFLQO.js").then((mod) => mod.Popup),
29
29
  {
30
30
  ssr: false
31
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@release0/nextjs",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "license": "FSL-1.1-ALv2",
5
5
  "description": "Relese0 Lib: A convenient library for displaying chat agents on Next.js websites",
6
6
  "type": "module",
@@ -17,22 +17,22 @@
17
17
  "build": "tsup"
18
18
  },
19
19
  "dependencies": {
20
- "@release0/js": "1.1.2"
20
+ "@release0/js": "1.1.6"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@release0/tsconfig": "0.0.1",
24
24
  "@types/react": "18.2.15",
25
25
  "tsup": "8.3.0",
26
26
  "react": "18.2.0",
27
- "@release0/react": "1.0.0",
27
+ "@release0/react": "1.0.1",
28
28
  "next": "14.2.13"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "react": "^16.0.0 || ^17.0.0 || ^18.0.0",
32
32
  "next": "12.x || 13.x || 14.x",
33
- "@release0/js": "^1.1.3 || workspace:*"
33
+ "@release0/js": "^1.1.6 || workspace:*"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  }
38
- }
38
+ }
@@ -1,80 +0,0 @@
1
- "use client"
2
-
3
- // ../react/dist/index.js
4
- import { useEffect, useRef } from "react";
5
- import "@release0/js/web";
6
- import { jsx } from "react/jsx-runtime";
7
- import { useCallback, useEffect as useEffect2, useRef as useRef2 } from "react";
8
- import "@release0/js/web";
9
- import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef3 } from "react";
10
- import "@release0/js/web";
11
- import { jsx as jsx2 } from "react/jsx-runtime";
12
- export * from "@release0/js";
13
- var Standard = ({ style, className, ...assignableProps }) => {
14
- const ref = useRef(null);
15
- useEffect(() => {
16
- if (!ref.current) return;
17
- Object.assign(ref.current, assignableProps);
18
- }, [assignableProps]);
19
- return /* @__PURE__ */ jsx("agent-standard", { ref, style, class: className });
20
- };
21
- var Bubble = (props) => {
22
- const bubbleElement = useRef2(null);
23
- const attachBubbleToDom = useCallback((props2) => {
24
- const newBubbleElement = document.createElement(
25
- "agent-bubble"
26
- );
27
- bubbleElement.current = newBubbleElement;
28
- injectPropsToElement(bubbleElement.current, props2);
29
- document.body.prepend(bubbleElement.current);
30
- }, []);
31
- useEffect2(() => {
32
- if (!bubbleElement.current) attachBubbleToDom(props);
33
- injectPropsToElement(bubbleElement.current, props);
34
- }, [attachBubbleToDom, props]);
35
- useEffect2(() => {
36
- return () => {
37
- bubbleElement.current?.remove();
38
- bubbleElement.current = null;
39
- };
40
- }, []);
41
- const injectPropsToElement = (element, props2) => {
42
- Object.assign(element, props2);
43
- };
44
- return null;
45
- };
46
- var Popup = (props) => {
47
- const containerRef = useRef3(null);
48
- const popupRef = useRef3(null);
49
- const attachPopupToContainer = useCallback2((props2) => {
50
- const popupElement = document.createElement("agent-popup");
51
- popupRef.current = popupElement;
52
- injectPropsToElement(popupRef.current, props2);
53
- if (!containerRef.current) {
54
- console.warn(
55
- "Could not attach popup to container because containerRef.current is null"
56
- );
57
- return;
58
- }
59
- containerRef.current?.append(popupRef.current);
60
- }, []);
61
- useEffect3(() => {
62
- if (!popupRef.current) attachPopupToContainer(props);
63
- injectPropsToElement(popupRef.current, props);
64
- }, [attachPopupToContainer, props]);
65
- useEffect3(() => {
66
- return () => {
67
- popupRef.current?.remove();
68
- popupRef.current = null;
69
- };
70
- }, []);
71
- const injectPropsToElement = (element, props2) => {
72
- Object.assign(element, props2);
73
- };
74
- return /* @__PURE__ */ jsx2("div", { ref: containerRef });
75
- };
76
- export {
77
- Bubble,
78
- Popup,
79
- Standard
80
- };