@buyingbuddy/react 0.0.2 → 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/LICENSE +21 -0
- package/README.md +31 -67
- package/dist/BuyingBuddyProvider.d.ts +3 -3
- package/dist/BuyingBuddyProvider.d.ts.map +1 -1
- package/dist/BuyingBuddyProvider.js +27 -14
- package/dist/BuyingBuddyProvider.js.map +1 -1
- package/dist/types.d.ts +16 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Blue Fire Group
|
|
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
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# @buyingbuddy/react
|
|
2
2
|
|
|
3
|
-
React components
|
|
3
|
+
Add IDX/MLS integration to your site with React components that embed [Buying Buddy IDX CRM](https://www.buyingbuddy.com) widgets - MLS property search, map-based results, detailed listing pages, featured-listing showcases, lead-capture forms, and market reports.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Buying Buddy widgets ship as a `<bb-widget>` custom element loaded from the Buying Buddy plugin script. This package wraps that element in idiomatic React components so you can add IDX search and listings to your site without writing script tags or touching the custom element directly.
|
|
6
6
|
|
|
7
7
|
Works with **React**, **Next.js**, and **Framer**.
|
|
8
8
|
|
|
9
|
-
> **Is this the right package for you?** This is a React component library — you use it inside a build-tooled project (Vite, Next.js, Framer) that compiles JSX/TypeScript. If you just want to drop a widget into a plain HTML page with a `<script>` tag, you don't need this package — use the standard widget install from your
|
|
9
|
+
> **Is this the right package for you?** This is a React component library — you use it inside a build-tooled project (Vite, Next.js, Framer) that compiles JSX/TypeScript. If you just want to drop a widget into a plain HTML page with a `<script>` tag, you don't need this package — use the standard widget install from your Buying Buddy account dashboard (**Widgets → Plugin Installation and Setup**) instead.
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
@@ -40,8 +40,10 @@ Then paste one of the examples below into `src/App.jsx` and save — the page re
|
|
|
40
40
|
|
|
41
41
|
Before anything will render, you need both of these:
|
|
42
42
|
|
|
43
|
-
1. **A
|
|
44
|
-
2. **Your domain authorized on that account.** An
|
|
43
|
+
1. **A Buying Buddy account activation key.** Find it in your dashboard under **Widgets → Plugin Installation and Setup**. There is no anonymous or "try it" mode — the widgets will not load without a valid activation key.
|
|
44
|
+
2. **Your domain authorized on that account.** An activation key only works on domains registered to its account. Running on an unauthorized domain produces an "invalid account / unauthorized domain" error.
|
|
45
|
+
|
|
46
|
+
**Don't have an account yet?** [Start a free trial](https://buyingbuddy.com/free-trial-idx-plugin.php) or [buy a license](https://buyingbuddy.com/order) to get your activation key.
|
|
45
47
|
|
|
46
48
|
## Quick start
|
|
47
49
|
|
|
@@ -50,35 +52,34 @@ import { BuyingBuddyProvider, BuyingBuddyWidget } from "@buyingbuddy/react";
|
|
|
50
52
|
|
|
51
53
|
export default function App() {
|
|
52
54
|
return (
|
|
53
|
-
<BuyingBuddyProvider
|
|
54
|
-
<BuyingBuddyWidget type="FeaturedGallery" limit
|
|
55
|
+
<BuyingBuddyProvider activationKey="account-activation-key">
|
|
56
|
+
<BuyingBuddyWidget type="FeaturedGallery" filter="limit:12" />
|
|
55
57
|
</BuyingBuddyProvider>
|
|
56
58
|
);
|
|
57
59
|
}
|
|
58
60
|
```
|
|
59
61
|
|
|
60
|
-
Replace `
|
|
62
|
+
Replace `account-activation-key` with your `activationKey`. The provider loads the Buying Buddy script for that account once, waits for it to initialize, then renders your widgets. While it loads it renders the `fallback` (nothing, by default).
|
|
61
63
|
|
|
62
64
|
## Examples
|
|
63
65
|
|
|
64
|
-
**A search form
|
|
66
|
+
**A standalone search form:**
|
|
65
67
|
|
|
66
68
|
```jsx
|
|
67
|
-
<BuyingBuddyProvider
|
|
69
|
+
<BuyingBuddyProvider activationKey="account-activation-key">
|
|
68
70
|
<BuyingBuddyWidget type="SearchForm" />
|
|
69
|
-
<BuyingBuddyWidget type="SearchResults" limit={24} order="price_desc" />
|
|
70
71
|
</BuyingBuddyProvider>
|
|
71
72
|
```
|
|
72
73
|
|
|
73
|
-
**FeaturedGallery / FeaturedList show the account's own (featured) listings**, with `limit
|
|
74
|
+
**FeaturedGallery / FeaturedList show the account's own (featured) listings**, with a `limit:` token in the filter capping how many:
|
|
74
75
|
|
|
75
76
|
```jsx
|
|
76
|
-
<BuyingBuddyWidget type="FeaturedGallery" limit
|
|
77
|
+
<BuyingBuddyWidget type="FeaturedGallery" filter="limit:12" />
|
|
77
78
|
```
|
|
78
79
|
|
|
79
|
-
> If the account has no listings of its own — e.g. a brand-new or demo account — this renders empty ("0 Found"). To show listings from the broader MLS instead,
|
|
80
|
+
> If the account has no listings of its own — e.g. a brand-new or demo account — this renders empty ("0 Found"). To show listings from the broader MLS instead, add search criteria to the `filter` (below).
|
|
80
81
|
|
|
81
|
-
**Driving a gallery by search criteria.**
|
|
82
|
+
**Driving a gallery by search criteria.** All options are expressed as `+`-joined tokens inside a single `filter` string — criteria, sort, and count alike. Use `FIELD()` for a field that accepts several values:
|
|
82
83
|
|
|
83
84
|
```jsx
|
|
84
85
|
{/* 6 listings over $300k, priced high-to-low */}
|
|
@@ -99,8 +100,7 @@ Replace `your-account-id` with your `acid`. The provider loads the BuyingBuddy s
|
|
|
99
100
|
```jsx
|
|
100
101
|
<BuyingBuddyWidget
|
|
101
102
|
type="SearchResults"
|
|
102
|
-
filter="city:Denver+price_min:300000"
|
|
103
|
-
order="price_desc"
|
|
103
|
+
filter="city:Denver+price_min:300000+orderby:price desc"
|
|
104
104
|
/>
|
|
105
105
|
```
|
|
106
106
|
|
|
@@ -110,16 +110,6 @@ Replace `your-account-id` with your `acid`. The provider loads the BuyingBuddy s
|
|
|
110
110
|
<BuyingBuddyWidget type="InteractiveMap" style={{ height: "600px" }} />
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
-
**Run a callback when a widget finishes loading** (memoize the handler — see [Caveats](#caveats--limitations)):
|
|
114
|
-
|
|
115
|
-
```jsx
|
|
116
|
-
import { useCallback } from "react";
|
|
117
|
-
|
|
118
|
-
const handleLoaded = useCallback(() => console.log("gallery ready"), []);
|
|
119
|
-
|
|
120
|
-
<BuyingBuddyWidget type="FeaturedGallery" onWidgetLoaded={handleLoaded} />
|
|
121
|
-
```
|
|
122
|
-
|
|
123
113
|
### Next.js
|
|
124
114
|
|
|
125
115
|
The provider runs entirely in the browser (it loads a script and reads `window`), so the file that renders it must be a **client component**. In the App Router, add the `"use client"` directive at the top of the file — it tells Next.js to run this component in the browser rather than only on the server.
|
|
@@ -133,9 +123,8 @@ import { BuyingBuddyProvider, BuyingBuddyWidget } from "@buyingbuddy/react";
|
|
|
133
123
|
|
|
134
124
|
export default function Page() {
|
|
135
125
|
return (
|
|
136
|
-
<BuyingBuddyProvider
|
|
137
|
-
<BuyingBuddyWidget type="
|
|
138
|
-
<BuyingBuddyWidget type="SearchResults" limit={24} />
|
|
126
|
+
<BuyingBuddyProvider activationKey="account-activation-key" fallback={<p>Loading…</p>}>
|
|
127
|
+
<BuyingBuddyWidget type="SearchResults" />
|
|
139
128
|
</BuyingBuddyProvider>
|
|
140
129
|
);
|
|
141
130
|
}
|
|
@@ -145,24 +134,22 @@ Because the widgets are client-only, their listing content is **not server-rende
|
|
|
145
134
|
|
|
146
135
|
### Framer
|
|
147
136
|
|
|
148
|
-
A standalone, single-file widget for the [Framer](https://www.framer.com) website builder is included at [`framer/BuyingBuddyWidget.tsx`](framer/BuyingBuddyWidget.tsx). It bundles the script loading and adds Framer property controls (
|
|
137
|
+
A standalone, single-file widget for the [Framer](https://www.framer.com) website builder is included at [`framer/BuyingBuddyWidget.tsx`](framer/BuyingBuddyWidget.tsx). It bundles the script loading and adds Framer property controls (activation key, widget type, filter), so you configure everything from Framer's design panel — no React code required.
|
|
149
138
|
|
|
150
139
|
1. Open the [`framer/BuyingBuddyWidget.tsx`](framer/BuyingBuddyWidget.tsx) file and copy its entire contents.
|
|
151
140
|
2. In Framer, go to **Assets → Code → +** and paste it in.
|
|
152
|
-
3. Drag the component onto your canvas and set your **
|
|
141
|
+
3. Drag the component onto your canvas and set your **activation key** in the property panel.
|
|
153
142
|
|
|
154
143
|
## API
|
|
155
144
|
|
|
156
145
|
### `<BuyingBuddyProvider>`
|
|
157
146
|
|
|
158
|
-
Loads the
|
|
147
|
+
Loads the Buying Buddy runtime for an account and makes it available to the widgets inside it. Use **one** provider, near the top of your tree.
|
|
159
148
|
|
|
160
149
|
| Prop | Type | Default | Description |
|
|
161
150
|
|------|------|---------|-------------|
|
|
162
|
-
| `
|
|
163
|
-
| `
|
|
164
|
-
| `children` | `ReactNode` | — | Rendered once the script loads. |
|
|
165
|
-
| `fallback` | `ReactNode` | `null` | Shown while the script is loading (not shown on error — see Caveats). |
|
|
151
|
+
| `activationKey` | `string` | — | **Required.** Your Buying Buddy account activation key. |
|
|
152
|
+
| `fallback` | `ReactNode` | `null` | Rendered while the script is loading. Not shown on error — see Caveats. |
|
|
166
153
|
|
|
167
154
|
### `<BuyingBuddyWidget>`
|
|
168
155
|
|
|
@@ -171,34 +158,11 @@ Renders a single widget. Must be a descendant of `<BuyingBuddyProvider>`.
|
|
|
171
158
|
| Prop | Type | Description |
|
|
172
159
|
|------|------|-------------|
|
|
173
160
|
| `type` | `BuyingBuddyWidgetType` | **Required.** Widget to render — e.g. `"FeaturedGallery"`, `"SearchForm"`, `"SearchResults"`, `"InteractiveMap"`, `"SearchDetails"`. |
|
|
174
|
-
| `filter` | `string` | Property filter
|
|
175
|
-
| `
|
|
176
|
-
| `order` | `string` | Sort order, e.g. `"price_asc"`, `"price_desc"`, `"date_listed_desc"`. |
|
|
177
|
-
| `demo` | `boolean \| string` | Sets the `demo` attribute on the widget element. |
|
|
178
|
-
| `featured` | `boolean \| string` | Show only featured listings. |
|
|
179
|
-
| `style` | `React.CSSProperties` | Inline styles for the **wrapper `<div>`** (not forwarded to the widget element). |
|
|
180
|
-
| `className` | `string` | CSS class(es) for the wrapper `<div>`. |
|
|
181
|
-
| `id` | `string` | HTML `id` attribute set on the widget element. |
|
|
182
|
-
| `onWidgetLoaded` | `() => void` | Fires once when the widget finishes loading. Memoize it (see Caveats). |
|
|
161
|
+
| `filter` | `string` | Property filter as `+`-joined tokens, e.g. `"city:Denver+FIELD(property_beds:3,4,5)+orderby:price desc+limit:9"`. |
|
|
162
|
+
| `style` | `React.CSSProperties` | Inline styles applied to the wrapper `<div>` (not forwarded to the widget element). Useful for sizing widgets such as `InteractiveMap`. |
|
|
183
163
|
|
|
184
164
|
Common `type` values include `FeaturedGallery`, `FeaturedList`, `SearchForm`, `SearchResults`, `SearchDetails`, `QuickSearch`, `InteractiveMap`, `Communities`, `LcForm` (lead capture), `LoginPanel`, `Calculator`, `MarketReport`, `MarketStats`, `Brokers`, `OfficeRoster`, and `Disclaimer`. The `type` prop accepts any string, so newer widget types work even before they're added to the typings.
|
|
185
165
|
|
|
186
|
-
### `useBuyingBuddy()`
|
|
187
|
-
|
|
188
|
-
Hook for reading the provider's load state. Throws if called outside a `<BuyingBuddyProvider>`.
|
|
189
|
-
|
|
190
|
-
```jsx
|
|
191
|
-
import { useBuyingBuddy } from "@buyingbuddy/react";
|
|
192
|
-
|
|
193
|
-
function Status() {
|
|
194
|
-
const { isLoaded, error, accountId } = useBuyingBuddy();
|
|
195
|
-
if (error) return <p>Failed to load: {error.message}</p>;
|
|
196
|
-
return <p>{isLoaded ? `Ready (${accountId})` : "Loading…"}</p>;
|
|
197
|
-
}
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
Returns `{ isLoaded: boolean, error: Error | null, accountId: string }`. Note that when `error` is set, the provider also renders its own built-in error message in place of `children`.
|
|
201
|
-
|
|
202
166
|
### TypeScript
|
|
203
167
|
|
|
204
168
|
The package is written in TypeScript and ships its own types. These are exported for your own typing needs:
|
|
@@ -214,13 +178,13 @@ import type {
|
|
|
214
178
|
|
|
215
179
|
## Caveats & limitations
|
|
216
180
|
|
|
217
|
-
- **One account per page.** The
|
|
181
|
+
- **One account per page.** The Buying Buddy script installs a single global, so a page is expected to use one `activationKey`. Rendering two providers with different activation keys on the same page is not supported.
|
|
218
182
|
- **Client-side only.** Widgets render in the browser after the script loads — nothing is server-rendered. There's no SSR/streaming output, so the listing content isn't in the initial HTML (relevant for SEO).
|
|
219
|
-
- **Changing a prop rebuilds the widget.** Changing `type
|
|
183
|
+
- **Changing a prop rebuilds the widget.** Changing `type` or `filter` tears down and recreates the underlying `<bb-widget>`, losing in-widget state (map position, scroll, form input).
|
|
220
184
|
- **The script persists after unmount.** Unmounting the provider does not remove the script or reset the global — remounting reuses the already-loaded runtime. This is intentional.
|
|
221
|
-
- **Error UI is built in.** On load failure the provider renders its own inline error message in place of `children` (and `fallback` is not shown). You can
|
|
185
|
+
- **Error UI is built in.** On load failure the provider renders its own inline error message in place of `children` (and `fallback` is not shown). You can't currently replace the default error UI.
|
|
222
186
|
- **ESM-only.** This package ships as ES modules only (no CommonJS build). Use it in a project with ESM/bundler support.
|
|
223
|
-
- **Pre-release.** This package is `0.0.
|
|
187
|
+
- **Pre-release.** This package is `0.0.2` — the API may change.
|
|
224
188
|
|
|
225
189
|
## Development
|
|
226
190
|
|
|
@@ -233,4 +197,4 @@ npm test # run the unit tests (vitest)
|
|
|
233
197
|
|
|
234
198
|
## License
|
|
235
199
|
|
|
236
|
-
|
|
200
|
+
[MIT](LICENSE) © Blue Fire Group / Buying Buddy
|
|
@@ -16,16 +16,16 @@ declare global {
|
|
|
16
16
|
/**
|
|
17
17
|
* Provides the BuyingBuddy runtime context to child components.
|
|
18
18
|
*
|
|
19
|
-
* Loads the MBB script tag for the given
|
|
19
|
+
* Loads the MBB script tag for the given activation key and exposes
|
|
20
20
|
* loading state via context. Widgets rendered as children will
|
|
21
21
|
* wait for the script to load before mounting.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* ```tsx
|
|
25
|
-
* <BuyingBuddyProvider
|
|
25
|
+
* <BuyingBuddyProvider activationKey="your-activation-key">
|
|
26
26
|
* <BuyingBuddyWidget type="FeaturedGallery" limit={12} />
|
|
27
27
|
* </BuyingBuddyProvider>
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
export declare function BuyingBuddyProvider({
|
|
30
|
+
export declare function BuyingBuddyProvider({ activationKey, domain, apiBaseUrl, children, fallback, }: BuyingBuddyProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
31
31
|
//# sourceMappingURL=BuyingBuddyProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuyingBuddyProvider.d.ts","sourceRoot":"","sources":["../src/BuyingBuddyProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAIjF;;;GAGG;AACH,wBAAgB,cAAc,IAAI,uBAAuB,CAQxD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,GAAG,CAAC,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC7B,UAAU,EAAE,MAAM,CAAC;YACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;SACxB,CAAC;KACH;CACF;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,
|
|
1
|
+
{"version":3,"file":"BuyingBuddyProvider.d.ts","sourceRoot":"","sources":["../src/BuyingBuddyProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAIjF;;;GAGG;AACH,wBAAgB,cAAc,IAAI,uBAAuB,CAQxD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,GAAG,CAAC,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC7B,UAAU,EAAE,MAAM,CAAC;YACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;SACxB,CAAC;KACH;CACF;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,aAAa,EACb,MAAuB,EACvB,UAAU,EACV,QAAQ,EACR,QAAe,GAChB,EAAE,wBAAwB,2CA+G1B"}
|
|
@@ -16,18 +16,23 @@ const LOADED_ACCOUNTS = new Set();
|
|
|
16
16
|
/**
|
|
17
17
|
* Provides the BuyingBuddy runtime context to child components.
|
|
18
18
|
*
|
|
19
|
-
* Loads the MBB script tag for the given
|
|
19
|
+
* Loads the MBB script tag for the given activation key and exposes
|
|
20
20
|
* loading state via context. Widgets rendered as children will
|
|
21
21
|
* wait for the script to load before mounting.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* ```tsx
|
|
25
|
-
* <BuyingBuddyProvider
|
|
25
|
+
* <BuyingBuddyProvider activationKey="your-activation-key">
|
|
26
26
|
* <BuyingBuddyWidget type="FeaturedGallery" limit={12} />
|
|
27
27
|
* </BuyingBuddyProvider>
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
export function BuyingBuddyProvider({
|
|
30
|
+
export function BuyingBuddyProvider({ activationKey, domain = "www.mbb2.com", apiBaseUrl, children, fallback = null, }) {
|
|
31
|
+
// Base URL for widget DATA requests. Defaults to the same environment as
|
|
32
|
+
// `domain`, but can be set independently to point data at another
|
|
33
|
+
// environment (e.g. a quick prod/preview flip for testing) without changing
|
|
34
|
+
// which bundle/theme `domain` loads.
|
|
35
|
+
const resolvedApiBaseUrl = apiBaseUrl ?? `https://${domain}`;
|
|
31
36
|
const [isLoaded, setIsLoaded] = useState(() => {
|
|
32
37
|
// If already loaded (e.g., script tag in HTML), skip loading
|
|
33
38
|
return typeof window !== "undefined" && !!window.MBB;
|
|
@@ -40,13 +45,16 @@ export function BuyingBuddyProvider({ accountId, domain = "www.mbb2.com", childr
|
|
|
40
45
|
let attempts = 0;
|
|
41
46
|
const check = () => {
|
|
42
47
|
if (window.MBB) {
|
|
43
|
-
|
|
48
|
+
// Set before the widget bundle (appended by the bootstrap, loaded
|
|
49
|
+
// async) makes its first data request, so DATA follows this base URL.
|
|
50
|
+
window.MBB.apiBaseUrl = resolvedApiBaseUrl;
|
|
51
|
+
LOADED_ACCOUNTS.add(activationKey);
|
|
44
52
|
setIsLoaded(true);
|
|
45
53
|
}
|
|
46
54
|
else if ("displayInvalidAcidMsg" in window ||
|
|
47
55
|
attempts >= 50) {
|
|
48
56
|
setError(new Error("displayInvalidAcidMsg" in window
|
|
49
|
-
? "BuyingBuddy: Invalid
|
|
57
|
+
? "BuyingBuddy: Invalid activation key or unauthorized domain. Check your activationKey and ensure this domain is registered in your BuyingBuddy dashboard."
|
|
50
58
|
: "BuyingBuddy script loaded but MBB global was not initialized."));
|
|
51
59
|
}
|
|
52
60
|
else {
|
|
@@ -55,7 +63,7 @@ export function BuyingBuddyProvider({ accountId, domain = "www.mbb2.com", childr
|
|
|
55
63
|
}
|
|
56
64
|
};
|
|
57
65
|
check();
|
|
58
|
-
}, [
|
|
66
|
+
}, [activationKey, resolvedApiBaseUrl]);
|
|
59
67
|
useEffect(() => {
|
|
60
68
|
if (typeof window === "undefined")
|
|
61
69
|
return;
|
|
@@ -65,20 +73,25 @@ export function BuyingBuddyProvider({ accountId, domain = "www.mbb2.com", childr
|
|
|
65
73
|
// `domain` as the API so the theme follows the environment (production vs
|
|
66
74
|
// preview) — if a given environment serves bad CSS, that's the
|
|
67
75
|
// environment's problem, not this package's.
|
|
68
|
-
const themeId = `mbb-theme-${
|
|
76
|
+
const themeId = `mbb-theme-${activationKey}`;
|
|
69
77
|
if (!document.getElementById(themeId)) {
|
|
70
78
|
const theme = document.createElement("script");
|
|
71
79
|
theme.id = themeId;
|
|
72
|
-
theme.src = `https://${domain}/version3/css/theme/acid/${
|
|
80
|
+
theme.src = `https://${domain}/version3/css/theme/acid/${activationKey}`;
|
|
73
81
|
theme.async = true;
|
|
74
82
|
document.head.appendChild(theme);
|
|
75
83
|
}
|
|
84
|
+
// If the runtime global already exists (this mount, a prior mount, or a
|
|
85
|
+
// script tag in the page), point data requests at the resolved base now.
|
|
86
|
+
if (window.MBB) {
|
|
87
|
+
window.MBB.apiBaseUrl = resolvedApiBaseUrl;
|
|
88
|
+
}
|
|
76
89
|
// Already loaded for this account
|
|
77
|
-
if (window.MBB && LOADED_ACCOUNTS.has(
|
|
90
|
+
if (window.MBB && LOADED_ACCOUNTS.has(activationKey)) {
|
|
78
91
|
setIsLoaded(true);
|
|
79
92
|
return;
|
|
80
93
|
}
|
|
81
|
-
const scriptId = `mbb-script-${
|
|
94
|
+
const scriptId = `mbb-script-${activationKey}`;
|
|
82
95
|
// Script tag already exists in the DOM
|
|
83
96
|
if (document.getElementById(scriptId)) {
|
|
84
97
|
handleLoad();
|
|
@@ -86,18 +99,18 @@ export function BuyingBuddyProvider({ accountId, domain = "www.mbb2.com", childr
|
|
|
86
99
|
}
|
|
87
100
|
const script = document.createElement("script");
|
|
88
101
|
script.id = scriptId;
|
|
89
|
-
script.src = `https://${domain}/mbbv3/index/acid/${
|
|
102
|
+
script.src = `https://${domain}/mbbv3/index/acid/${activationKey}`;
|
|
90
103
|
script.async = true;
|
|
91
104
|
script.onload = handleLoad;
|
|
92
105
|
script.onerror = () => {
|
|
93
|
-
setError(new Error(`Failed to load BuyingBuddy script for account: ${
|
|
106
|
+
setError(new Error(`Failed to load BuyingBuddy script for account: ${activationKey}`));
|
|
94
107
|
};
|
|
95
108
|
document.head.appendChild(script);
|
|
96
109
|
return () => {
|
|
97
110
|
// Don't remove the script on unmount — MBB global state is persistent
|
|
98
111
|
};
|
|
99
|
-
}, [
|
|
100
|
-
const value = { isLoaded, error,
|
|
112
|
+
}, [activationKey, domain, resolvedApiBaseUrl, handleLoad]);
|
|
113
|
+
const value = { isLoaded, error, activationKey };
|
|
101
114
|
return (_jsx(BuyingBuddyContext.Provider, { value: value, children: error ? (_jsxs("div", { role: "alert", style: { color: "#b91c1c", padding: "12px", border: "1px solid #fca5a5", borderRadius: "6px", backgroundColor: "#fef2f2", fontFamily: "sans-serif", fontSize: "14px" }, children: [_jsx("strong", { children: "BuyingBuddy Error:" }), " ", error.message] })) : isLoaded ? children : fallback }));
|
|
102
115
|
}
|
|
103
116
|
//# sourceMappingURL=BuyingBuddyProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuyingBuddyProvider.js","sourceRoot":"","sources":["../src/BuyingBuddyProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAGpF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E,CAAC;QACJ,CAAC,CAAC;QAEF,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAElC,OAAO,GAAG,EAAE;YACV,sEAAsE;QACxE,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,kBAAkB,EAAE,UAAU,CAAC,CAAC,CAAC;IAE5D,MAAM,KAAK,GAA4B,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;IAE1E,OAAO,CACL,KAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACtC,KAAK,CAAC,CAAC,CAAC,CACP,eAAK,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,aACtL,kDAAmC,OAAE,KAAK,CAAC,OAAO,IAC9C,CACP,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,GACN,CAC/B,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -47,15 +47,24 @@ export interface BuyingBuddyWidgetProps {
|
|
|
47
47
|
*/
|
|
48
48
|
export interface BuyingBuddyProviderProps {
|
|
49
49
|
/**
|
|
50
|
-
* Your BuyingBuddy account
|
|
51
|
-
* This is the `acid` value from your BuyingBuddy account.
|
|
50
|
+
* Your BuyingBuddy activation key — the `acid` value from your account.
|
|
52
51
|
*/
|
|
53
|
-
|
|
52
|
+
activationKey: string;
|
|
54
53
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
54
|
+
* Domain the runtime script, theme, and config are loaded from.
|
|
55
|
+
* Defaults to "www.mbb2.com". This selects which environment's widget
|
|
56
|
+
* bundle and theme you get (e.g. "preview.mbb2.com" for preview).
|
|
57
|
+
* Only change this if directed by BuyingBuddy support or for testing.
|
|
57
58
|
*/
|
|
58
59
|
domain?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Base URL for widget DATA requests (`window.MBB.apiBaseUrl`).
|
|
62
|
+
* Defaults to `https://{domain}`, so data follows the same environment as
|
|
63
|
+
* `domain`. Set it explicitly to point data at a different environment
|
|
64
|
+
* independently of the bundle/theme — e.g. a quick prod/preview flip for
|
|
65
|
+
* testing. Example: "https://preview.mbb2.com".
|
|
66
|
+
*/
|
|
67
|
+
apiBaseUrl?: string;
|
|
59
68
|
/** Children to render once the script is loaded. */
|
|
60
69
|
children: React.ReactNode;
|
|
61
70
|
/**
|
|
@@ -72,7 +81,7 @@ export interface BuyingBuddyContextValue {
|
|
|
72
81
|
isLoaded: boolean;
|
|
73
82
|
/** Error if the script failed to load. */
|
|
74
83
|
error: Error | null;
|
|
75
|
-
/** The
|
|
76
|
-
|
|
84
|
+
/** The activation key passed to the provider. */
|
|
85
|
+
activationKey: string;
|
|
77
86
|
}
|
|
78
87
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAC7B,aAAa,GACb,iBAAiB,GACjB,cAAc,GACd,gBAAgB,GAChB,YAAY,GACZ,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,eAAe,GACf,aAAa,GACb,iBAAiB,GACjB,SAAS,GACT,YAAY,GACZ,QAAQ,GACR,YAAY,GACZ,SAAS,GACT,cAAc,GACd,YAAY,GACZ,cAAc,GACd,aAAa,GACb,YAAY,GACZ,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC,uCAAuC;IACvC,IAAI,EAAE,qB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,CAAC;IAEf;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAExB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAE5B,8DAA8D;IAC9D,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAE5B,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,yBAAyB;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ,mEAAmE;IACnE,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,oDAAoD;IACpD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,mDAAmD;IACnD,QAAQ,EAAE,OAAO,CAAC;IAElB,0CAA0C;IAC1C,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAEpB,iDAAiD;IACjD,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buyingbuddy/react",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "React wrapper for BuyingBuddy Web Component widgets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,13 +37,23 @@
|
|
|
37
37
|
},
|
|
38
38
|
"keywords": [
|
|
39
39
|
"buyingbuddy",
|
|
40
|
-
"react",
|
|
41
40
|
"web-components",
|
|
41
|
+
"nextjs",
|
|
42
|
+
"framer",
|
|
42
43
|
"real-estate",
|
|
43
44
|
"idx",
|
|
44
|
-
"
|
|
45
|
+
"idx-search",
|
|
46
|
+
"mls",
|
|
47
|
+
"mls-integration",
|
|
48
|
+
"property-listings",
|
|
49
|
+
"property-search",
|
|
50
|
+
"real-estate-crm",
|
|
51
|
+
"real-estate-marketing"
|
|
45
52
|
],
|
|
46
|
-
"license": "
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
},
|
|
47
57
|
"repository": {
|
|
48
58
|
"type": "git",
|
|
49
59
|
"url": "https://github.com/Blue-Fire-Group/buyingbuddy.git",
|