@drippr/embed-react 0.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 +228 -0
- package/dist/index.d.mts +63 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +628 -0
- package/dist/index.mjs +591 -0
- package/package.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# @drippr/embed-react
|
|
2
|
+
|
|
3
|
+
React component for embedding Drippr feedback flows into your application. Supports inline, modal, and drawer display modes.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @drippr/embed-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { DripprFlow } from "@drippr/embed-react";
|
|
15
|
+
|
|
16
|
+
function App() {
|
|
17
|
+
return (
|
|
18
|
+
<DripprFlow
|
|
19
|
+
flowId="your-flow-public-key"
|
|
20
|
+
mode="inline"
|
|
21
|
+
onSubmitted={() => console.log("Feedback submitted!")}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage Examples
|
|
28
|
+
|
|
29
|
+
### Inline Mode
|
|
30
|
+
|
|
31
|
+
Embed the flow directly in your page:
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { DripprFlow } from "@drippr/embed-react";
|
|
35
|
+
|
|
36
|
+
function FeedbackSection() {
|
|
37
|
+
return (
|
|
38
|
+
<div>
|
|
39
|
+
<h2>Share Your Feedback</h2>
|
|
40
|
+
<DripprFlow
|
|
41
|
+
flowId="your-flow-public-key"
|
|
42
|
+
mode="inline"
|
|
43
|
+
onSubmitted={() => alert("Thank you for your feedback!")}
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Modal Mode
|
|
51
|
+
|
|
52
|
+
Open the flow in a modal dialog:
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { DripprFlow } from "@drippr/embed-react";
|
|
56
|
+
|
|
57
|
+
function FeedbackButton() {
|
|
58
|
+
return (
|
|
59
|
+
<DripprFlow
|
|
60
|
+
flowId="your-flow-public-key"
|
|
61
|
+
mode="modal"
|
|
62
|
+
triggerLabel="Give Feedback"
|
|
63
|
+
onSubmitted={() => console.log("Done!")}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Custom Trigger:**
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
<DripprFlow flowId="your-flow-public-key" mode="modal">
|
|
73
|
+
{({ open }) => (
|
|
74
|
+
<button onClick={open} className="custom-button">
|
|
75
|
+
Open Feedback Modal
|
|
76
|
+
</button>
|
|
77
|
+
)}
|
|
78
|
+
</DripprFlow>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Drawer Mode
|
|
82
|
+
|
|
83
|
+
Open the flow in a side drawer:
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { DripprFlow } from "@drippr/embed-react";
|
|
87
|
+
|
|
88
|
+
function FeedbackDrawer() {
|
|
89
|
+
return (
|
|
90
|
+
<DripprFlow
|
|
91
|
+
flowId="your-flow-public-key"
|
|
92
|
+
mode="drawer"
|
|
93
|
+
triggerLabel="Feedback"
|
|
94
|
+
onSubmitted={() => console.log("Done!")}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Controlled Drawer:**
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import { useState } from "react";
|
|
104
|
+
import { DripprFlow } from "@drippr/embed-react";
|
|
105
|
+
|
|
106
|
+
function ControlledDrawer() {
|
|
107
|
+
const [open, setOpen] = useState(false);
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<>
|
|
111
|
+
<button onClick={() => setOpen(true)}>Open Drawer</button>
|
|
112
|
+
<DripprFlow
|
|
113
|
+
flowId="your-flow-public-key"
|
|
114
|
+
mode="drawer"
|
|
115
|
+
open={open}
|
|
116
|
+
onOpenChange={setOpen}
|
|
117
|
+
/>
|
|
118
|
+
</>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Props
|
|
124
|
+
|
|
125
|
+
### DripprFlowProps
|
|
126
|
+
|
|
127
|
+
| Prop | Type | Required | Default | Description |
|
|
128
|
+
|------|------|----------|---------|-------------|
|
|
129
|
+
| `flowId` | `string` | Yes | - | The flow's public key from your Drippr dashboard |
|
|
130
|
+
| `mode` | `"inline" \| "modal" \| "drawer"` | No | `"inline"` | How to display the flow |
|
|
131
|
+
| `open` | `boolean` | No | - | Controlled open state (for modal/drawer) |
|
|
132
|
+
| `onOpenChange` | `(open: boolean) => void` | No | - | Callback when open state changes |
|
|
133
|
+
| `prefill` | `PrefillData` | No | - | Pre-fill contact form fields |
|
|
134
|
+
| `children` | `(api: DripprFlowApi) => ReactNode` | No | - | Render prop for custom trigger (modal/drawer only) |
|
|
135
|
+
| `triggerLabel` | `string` | No | `"Give Feedback"` | Default trigger label when no children provided |
|
|
136
|
+
| `onSubmitted` | `() => void` | No | - | Called when the user completes the flow |
|
|
137
|
+
| `className` | `string` | No | - | Additional CSS class for the container |
|
|
138
|
+
| `style` | `React.CSSProperties` | No | - | Inline styles for the container |
|
|
139
|
+
| `height` | `number` | No | `700` | Fallback height for the iframe (px) |
|
|
140
|
+
| `baseUrl` | `string` | No | `"https://app.drippr.io"` | Base URL for the embed |
|
|
141
|
+
|
|
142
|
+
### PrefillData
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
interface PrefillData {
|
|
146
|
+
email?: string;
|
|
147
|
+
company?: string;
|
|
148
|
+
name?: string;
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Example:**
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
<DripprFlow
|
|
156
|
+
flowId="your-flow-public-key"
|
|
157
|
+
mode="inline"
|
|
158
|
+
prefill={{
|
|
159
|
+
email: "user@example.com",
|
|
160
|
+
name: "John Doe",
|
|
161
|
+
company: "Acme Inc"
|
|
162
|
+
}}
|
|
163
|
+
/>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### DripprFlowApi
|
|
167
|
+
|
|
168
|
+
The API object provided to render prop children:
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
interface DripprFlowApi {
|
|
172
|
+
open: () => void;
|
|
173
|
+
close: () => void;
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Features
|
|
178
|
+
|
|
179
|
+
- **Three Display Modes**: Inline, modal, and drawer
|
|
180
|
+
- **Controlled & Uncontrolled**: Support for both controlled and uncontrolled state
|
|
181
|
+
- **Custom Triggers**: Use render props to create custom trigger buttons
|
|
182
|
+
- **Prefill Support**: Pre-populate form fields with user data
|
|
183
|
+
- **Auto-resize**: Iframe automatically resizes based on content
|
|
184
|
+
- **TypeScript**: Full TypeScript support with exported types
|
|
185
|
+
- **React 18+**: Built for React 18 and above
|
|
186
|
+
|
|
187
|
+
## Requirements
|
|
188
|
+
|
|
189
|
+
- React >= 18.0.0
|
|
190
|
+
- React DOM >= 18.0.0
|
|
191
|
+
|
|
192
|
+
## TypeScript
|
|
193
|
+
|
|
194
|
+
All types are exported for use in your TypeScript projects:
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
import type {
|
|
198
|
+
DripprFlowProps,
|
|
199
|
+
DripprFlowApi,
|
|
200
|
+
PrefillData,
|
|
201
|
+
EmbedMode,
|
|
202
|
+
} from "@drippr/embed-react";
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Development
|
|
206
|
+
|
|
207
|
+
For local development:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Install dependencies
|
|
211
|
+
npm install
|
|
212
|
+
|
|
213
|
+
# Build the package
|
|
214
|
+
npm run build
|
|
215
|
+
|
|
216
|
+
# Watch mode for development
|
|
217
|
+
npm run dev
|
|
218
|
+
|
|
219
|
+
# Type check
|
|
220
|
+
npm run typecheck
|
|
221
|
+
|
|
222
|
+
# Lint
|
|
223
|
+
npm run lint
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## License
|
|
227
|
+
|
|
228
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface PrefillData {
|
|
4
|
+
email?: string;
|
|
5
|
+
company?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
}
|
|
8
|
+
type DripprMessageFromChild = {
|
|
9
|
+
type: "drippr:ready";
|
|
10
|
+
flowId: string;
|
|
11
|
+
instanceId: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: "drippr:resize";
|
|
14
|
+
flowId: string;
|
|
15
|
+
instanceId: string;
|
|
16
|
+
height: number;
|
|
17
|
+
} | {
|
|
18
|
+
type: "drippr:submitted";
|
|
19
|
+
flowId: string;
|
|
20
|
+
instanceId: string;
|
|
21
|
+
dropId?: string;
|
|
22
|
+
};
|
|
23
|
+
type DripprMessageToChild = {
|
|
24
|
+
type: "drippr:prefill";
|
|
25
|
+
instanceId: string;
|
|
26
|
+
payload: PrefillData;
|
|
27
|
+
};
|
|
28
|
+
type DripprMessage = DripprMessageFromChild | DripprMessageToChild;
|
|
29
|
+
type EmbedMode = "inline" | "modal" | "drawer";
|
|
30
|
+
interface DripprFlowApi {
|
|
31
|
+
open: () => void;
|
|
32
|
+
close: () => void;
|
|
33
|
+
}
|
|
34
|
+
interface DripprFlowProps {
|
|
35
|
+
/** The flow's public ID (from your Drippr dashboard) */
|
|
36
|
+
flowId: string;
|
|
37
|
+
/** How to display the flow: inline, modal, or drawer */
|
|
38
|
+
mode?: EmbedMode;
|
|
39
|
+
/** Controlled open state (for modal/drawer) */
|
|
40
|
+
open?: boolean;
|
|
41
|
+
/** Callback when open state changes */
|
|
42
|
+
onOpenChange?: (open: boolean) => void;
|
|
43
|
+
/** Pre-fill contact form fields */
|
|
44
|
+
prefill?: PrefillData;
|
|
45
|
+
/** Render prop for custom trigger (modal/drawer only) */
|
|
46
|
+
children?: (api: DripprFlowApi) => React.ReactNode;
|
|
47
|
+
/** Default trigger label when no children provided (modal/drawer only) */
|
|
48
|
+
triggerLabel?: string;
|
|
49
|
+
/** Called when the user completes the flow */
|
|
50
|
+
onSubmitted?: () => void;
|
|
51
|
+
/** Additional CSS class for the container */
|
|
52
|
+
className?: string;
|
|
53
|
+
/** Inline styles for the container */
|
|
54
|
+
style?: React.CSSProperties;
|
|
55
|
+
/** Fallback height for the iframe (default: 700) */
|
|
56
|
+
height?: number;
|
|
57
|
+
/** Base URL for the embed (defaults to production) */
|
|
58
|
+
baseUrl?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
declare function DripprFlow({ flowId, mode, open: controlledOpen, onOpenChange, prefill, children, triggerLabel, onSubmitted, className, style, height: fallbackHeight, baseUrl, }: DripprFlowProps): react_jsx_runtime.JSX.Element | null;
|
|
62
|
+
|
|
63
|
+
export { DripprFlow, type DripprFlowApi, type DripprFlowProps, type DripprMessage, type DripprMessageFromChild, type DripprMessageToChild, type EmbedMode, type PrefillData };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface PrefillData {
|
|
4
|
+
email?: string;
|
|
5
|
+
company?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
}
|
|
8
|
+
type DripprMessageFromChild = {
|
|
9
|
+
type: "drippr:ready";
|
|
10
|
+
flowId: string;
|
|
11
|
+
instanceId: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: "drippr:resize";
|
|
14
|
+
flowId: string;
|
|
15
|
+
instanceId: string;
|
|
16
|
+
height: number;
|
|
17
|
+
} | {
|
|
18
|
+
type: "drippr:submitted";
|
|
19
|
+
flowId: string;
|
|
20
|
+
instanceId: string;
|
|
21
|
+
dropId?: string;
|
|
22
|
+
};
|
|
23
|
+
type DripprMessageToChild = {
|
|
24
|
+
type: "drippr:prefill";
|
|
25
|
+
instanceId: string;
|
|
26
|
+
payload: PrefillData;
|
|
27
|
+
};
|
|
28
|
+
type DripprMessage = DripprMessageFromChild | DripprMessageToChild;
|
|
29
|
+
type EmbedMode = "inline" | "modal" | "drawer";
|
|
30
|
+
interface DripprFlowApi {
|
|
31
|
+
open: () => void;
|
|
32
|
+
close: () => void;
|
|
33
|
+
}
|
|
34
|
+
interface DripprFlowProps {
|
|
35
|
+
/** The flow's public ID (from your Drippr dashboard) */
|
|
36
|
+
flowId: string;
|
|
37
|
+
/** How to display the flow: inline, modal, or drawer */
|
|
38
|
+
mode?: EmbedMode;
|
|
39
|
+
/** Controlled open state (for modal/drawer) */
|
|
40
|
+
open?: boolean;
|
|
41
|
+
/** Callback when open state changes */
|
|
42
|
+
onOpenChange?: (open: boolean) => void;
|
|
43
|
+
/** Pre-fill contact form fields */
|
|
44
|
+
prefill?: PrefillData;
|
|
45
|
+
/** Render prop for custom trigger (modal/drawer only) */
|
|
46
|
+
children?: (api: DripprFlowApi) => React.ReactNode;
|
|
47
|
+
/** Default trigger label when no children provided (modal/drawer only) */
|
|
48
|
+
triggerLabel?: string;
|
|
49
|
+
/** Called when the user completes the flow */
|
|
50
|
+
onSubmitted?: () => void;
|
|
51
|
+
/** Additional CSS class for the container */
|
|
52
|
+
className?: string;
|
|
53
|
+
/** Inline styles for the container */
|
|
54
|
+
style?: React.CSSProperties;
|
|
55
|
+
/** Fallback height for the iframe (default: 700) */
|
|
56
|
+
height?: number;
|
|
57
|
+
/** Base URL for the embed (defaults to production) */
|
|
58
|
+
baseUrl?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
declare function DripprFlow({ flowId, mode, open: controlledOpen, onOpenChange, prefill, children, triggerLabel, onSubmitted, className, style, height: fallbackHeight, baseUrl, }: DripprFlowProps): react_jsx_runtime.JSX.Element | null;
|
|
62
|
+
|
|
63
|
+
export { DripprFlow, type DripprFlowApi, type DripprFlowProps, type DripprMessage, type DripprMessageFromChild, type DripprMessageToChild, type EmbedMode, type PrefillData };
|