@perspective-ai/sdk-react 1.1.2 → 1.1.4-pr-21-20260225112819
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 +50 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ function App() {
|
|
|
33
33
|
| ---------------- | --------- | -------------------------------------- |
|
|
34
34
|
| `usePopup` | Hook | Open popup modal programmatically |
|
|
35
35
|
| `useSlider` | Hook | Open slider panel programmatically |
|
|
36
|
+
| `useAutoOpen` | Hook | Auto-trigger popup (timeout/exit) |
|
|
36
37
|
| `useFloatBubble` | Hook | Floating chat bubble lifecycle |
|
|
37
38
|
| `Widget` | Component | Inline embed in a container |
|
|
38
39
|
| `Fullpage` | Component | Full viewport takeover |
|
|
@@ -110,6 +111,53 @@ function App() {
|
|
|
110
111
|
}
|
|
111
112
|
```
|
|
112
113
|
|
|
114
|
+
### useAutoOpen
|
|
115
|
+
|
|
116
|
+
Auto-trigger a popup based on a timeout or exit intent — no user click needed.
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
import { useAutoOpen } from "@perspective-ai/sdk-react";
|
|
120
|
+
|
|
121
|
+
function FeedbackTrigger() {
|
|
122
|
+
const { cancel, triggered } = useAutoOpen({
|
|
123
|
+
researchId: "your-research-id",
|
|
124
|
+
trigger: { type: "timeout", delay: 5000 },
|
|
125
|
+
showOnce: "session",
|
|
126
|
+
onSubmit: () => console.log("Completed!"),
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Renders nothing — popup opens automatically after 5s
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Exit intent:**
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
useAutoOpen({
|
|
138
|
+
researchId: "your-research-id",
|
|
139
|
+
trigger: { type: "exit-intent" },
|
|
140
|
+
showOnce: "visitor",
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Options:**
|
|
145
|
+
|
|
146
|
+
| Option | Type | Default | Description |
|
|
147
|
+
| ------------ | --------------- | ----------- | ------------------------------------------------------------------------ |
|
|
148
|
+
| `researchId` | `string` | — | Research ID (required) |
|
|
149
|
+
| `trigger` | `TriggerConfig` | — | `{ type: "timeout", delay: ms }` or `{ type: "exit-intent" }` (required) |
|
|
150
|
+
| `showOnce` | `ShowOnce` | `"session"` | `"session"`, `"visitor"`, or `false` |
|
|
151
|
+
|
|
152
|
+
Plus all standard `EmbedConfig` options (`theme`, `params`, `brand`, callbacks).
|
|
153
|
+
|
|
154
|
+
**Returns:**
|
|
155
|
+
|
|
156
|
+
| Property | Type | Description |
|
|
157
|
+
| ----------- | ------------ | ----------------------------- |
|
|
158
|
+
| `cancel` | `() => void` | Cancel the pending trigger |
|
|
159
|
+
| `triggered` | `boolean` | Whether the trigger has fired |
|
|
160
|
+
|
|
113
161
|
### useFloatBubble
|
|
114
162
|
|
|
115
163
|
Manage a floating chat bubble lifecycle.
|
|
@@ -263,6 +311,8 @@ import type {
|
|
|
263
311
|
UseSliderReturn,
|
|
264
312
|
UseFloatBubbleOptions,
|
|
265
313
|
UseFloatBubbleReturn,
|
|
314
|
+
UseAutoOpenOptions,
|
|
315
|
+
UseAutoOpenReturn,
|
|
266
316
|
// Component types
|
|
267
317
|
WidgetProps,
|
|
268
318
|
FloatBubbleProps,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perspective-ai/sdk-react",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4-pr-21-20260225112819",
|
|
4
4
|
"description": "React components for Perspective AI embed SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@perspective-ai/sdk": "^1.1.
|
|
59
|
+
"@perspective-ai/sdk": "^1.1.4-pr-21-20260225112819"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@testing-library/dom": "^10.4.1",
|