@alfredo-ai/leads-widget 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/LICENSE +21 -0
- package/README.md +162 -0
- package/dist/style.css +1 -0
- package/dist/vite.svg +1 -0
- package/dist/widget.js +47825 -0
- package/dist/widget.umd.cjs +330 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Alfredo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# @alfredo/leads-widget
|
|
2
|
+
|
|
3
|
+
Embeddable leads widget with optional SMS validation, designed for Alfredo and PropData integration. Built with React, Material UI, Redux, and TailwindCSS.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Multi-step lead form (location, characteristics, personal data, optional SMS validation)
|
|
8
|
+
- Multi-language support (Portuguese, English, Spanish)
|
|
9
|
+
- Google Maps integration for location selection
|
|
10
|
+
- Price interval / estimation display
|
|
11
|
+
- Optional SMS verification flow
|
|
12
|
+
- Theming via `primaryColor` and `backgroundColor`
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
### Via npm
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @alfredo/leads-widget
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Via script tag (CDN)
|
|
23
|
+
|
|
24
|
+
No install required. Load the UMD bundle directly (see [Script tag usage](#script-tag-umd) below).
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
### Script tag (UMD)
|
|
31
|
+
|
|
32
|
+
1. Add a container element where the widget should render:
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<div id="leads-widget-root"></div>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
2. Load the widget script and styles:
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<script src="https://unpkg.com/@alfredo/leads-widget/dist/widget.umd.cjs"></script>
|
|
42
|
+
<link rel="stylesheet" href="https://unpkg.com/@alfredo/leads-widget/dist/style.css" />
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
3. Initialize the widget:
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<script>
|
|
49
|
+
window.initLeadsWidget({
|
|
50
|
+
token: "YOUR_ALFREDO_LEADS_TOKEN",
|
|
51
|
+
container: "leads-widget-root",
|
|
52
|
+
origin: "pt",
|
|
53
|
+
});
|
|
54
|
+
</script>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### NPM / ESM (React or any bundler)
|
|
58
|
+
|
|
59
|
+
Import the package so that `initLeadsWidget` is attached to `window`, then call it once the container element is in the DOM:
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
import "@alfredo/leads-widget";
|
|
63
|
+
import "@alfredo/leads-widget/style.css";
|
|
64
|
+
|
|
65
|
+
window.initLeadsWidget({
|
|
66
|
+
token: "YOUR_ALFREDO_LEADS_TOKEN",
|
|
67
|
+
container: "leads-widget-root",
|
|
68
|
+
origin: "pt",
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Example in a React component:
|
|
73
|
+
|
|
74
|
+
```jsx
|
|
75
|
+
import { useEffect } from "react";
|
|
76
|
+
import "@alfredo/leads-widget";
|
|
77
|
+
import "@alfredo/leads-widget/style.css";
|
|
78
|
+
|
|
79
|
+
function LeadsWidget() {
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
window.initLeadsWidget({
|
|
82
|
+
token: "YOUR_ALFREDO_LEADS_TOKEN",
|
|
83
|
+
container: "leads-widget-root",
|
|
84
|
+
origin: "pt",
|
|
85
|
+
});
|
|
86
|
+
}, []);
|
|
87
|
+
|
|
88
|
+
return <div id="leads-widget-root" />;
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Configuration options
|
|
95
|
+
|
|
96
|
+
| Option | Type | Default | Description |
|
|
97
|
+
| ----------------- | ------- | ----------- | ------------------------------------------------- |
|
|
98
|
+
| `container` | string | `"root"` | DOM id of the element where the widget mounts. |
|
|
99
|
+
| `origin` | string | `"pt"` | Origin/locale key (`"pt"`, `"es"`, `"gb"`). |
|
|
100
|
+
| `userID` | string | `null` | Optional user identifier. |
|
|
101
|
+
| `lang` | string | `null` | Preferred language (`pt`, `en`, `es`). |
|
|
102
|
+
| `token` | string | - | Alfredo leads API token. |
|
|
103
|
+
| `showHeader` | boolean | `true` | Whether to show the widget header. |
|
|
104
|
+
| `primaryColor` | string | `"#009de0"` | Primary theme color (hex). |
|
|
105
|
+
| `backgroundColor` | string | `"#f7f7f7"` | Background color (hex). |
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Development
|
|
110
|
+
|
|
111
|
+
### Prerequisites
|
|
112
|
+
|
|
113
|
+
- Node.js >= 18
|
|
114
|
+
|
|
115
|
+
### Commands
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Install dependencies
|
|
119
|
+
npm install
|
|
120
|
+
|
|
121
|
+
# Start dev server (with hot reload)
|
|
122
|
+
npm run dev
|
|
123
|
+
|
|
124
|
+
# Production build (outputs to dist/)
|
|
125
|
+
npm run build
|
|
126
|
+
|
|
127
|
+
# Preview production build locally
|
|
128
|
+
npm run preview
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Test the built widget locally
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
npm run build
|
|
135
|
+
node serve
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Then open http://localhost:3002 to see the widget running from the UMD build.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Publishing to npm
|
|
143
|
+
|
|
144
|
+
1. Log in to npm (if not already):
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
npm login
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
2. Publish (scoped packages need `--access public`):
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
npm publish --access public
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
The `prepublishOnly` script automatically runs `npm run build` before publishing.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
|
|
162
|
+
MIT. See [LICENSE](LICENSE) for details.
|