@sonordev/site-kit 7.0.0 → 7.0.2
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/CHANGELOG.md +3539 -0
- package/README.md +12 -13
- package/agent-manifest.json +1 -1
- package/dist/{AnalyticsProvider-GJ6JFQO5.js → AnalyticsProvider-XXWTFKJH.js} +4 -4
- package/dist/{ArticleViewTracker-FEA5SBKW.js → ArticleViewTracker-V4KZB6QN.js} +3 -3
- package/dist/{BlocksPopup-MNK4SDZM.js → BlocksPopup-JHGHB6XW.js} +4 -4
- package/dist/{ChatWidget-M2YNLRYW.js → ChatWidget-CG32POI3.js} +5 -5
- package/dist/{EngageWidget-RR63JQCA.js → EngageWidget-LQMR4LEX.js} +4 -4
- package/dist/{FileField-JFBXXD43.js → FileField-KUG3CKXG.js} +3 -3
- package/dist/{FormSpotlight-QE3J3VB5.js → FormSpotlight-FVNPOCU3.js} +1 -1
- package/dist/{FormStage-OTPKEWID.js → FormStage-C7VKRURJ.js} +1 -1
- package/dist/{ManagedForm-3VRALWUD.js → ManagedForm-VLNJKV65.js} +6 -6
- package/dist/{ManagedNewsletterForm-A2FE6L5C.js → ManagedNewsletterForm-KJEU23BV.js} +4 -4
- package/dist/{SignalCore-S6DO3VQV.js → SignalCore-K2O46QG7.js} +3 -3
- package/dist/{SiteDesignReporter-2WZVWJMA.js → SiteDesignReporter-D7MD66GI.js} +5 -5
- package/dist/SitemapSync-NMXGMPCQ.js +8 -0
- package/dist/_client/booking-widget.js +5 -5
- package/dist/affiliates/index.js +3 -3
- package/dist/analytics/index.js +4 -4
- package/dist/articles/index.js +1 -1
- package/dist/articles/server-ui.js +1 -1
- package/dist/chat/index.js +5 -5
- package/dist/{chunk-XZMVNORA.js → chunk-42OXY4JV.js} +1 -1
- package/dist/{chunk-5YSI5KFD.js → chunk-56JNI463.js} +1 -1
- package/dist/{chunk-M4ZY2FVB.js → chunk-5FBY2ZIH.js} +1 -1
- package/dist/{chunk-3XHK5DFX.js → chunk-7JIKGKWD.js} +7 -7
- package/dist/{chunk-7ZHJIRM3.js → chunk-B6RZ2NRH.js} +1 -1
- package/dist/{chunk-UINSEWQ3.js → chunk-BEL7YFMC.js} +1 -1
- package/dist/{chunk-R3TOKUDJ.js → chunk-BS7FWUOY.js} +1 -1
- package/dist/{chunk-MZFF5F7R.js → chunk-DKTSGYLM.js} +2 -2
- package/dist/{chunk-LT5ITURG.js → chunk-GGD4P7UW.js} +1 -1
- package/dist/{chunk-OO2GZ272.js → chunk-GYY6ETGB.js} +1 -1
- package/dist/{chunk-I6WUCBKI.js → chunk-K5WZX776.js} +2 -2
- package/dist/{chunk-B52EXDWI.js → chunk-LJZ3SUET.js} +2 -2
- package/dist/{chunk-OSQHWIM5.js → chunk-O52CH273.js} +1 -1
- package/dist/{chunk-HPUXKMNR.js → chunk-OIETJKIL.js} +1 -1
- package/dist/{chunk-5UZN5V52.js → chunk-P2GIIQH5.js} +1 -1
- package/dist/{chunk-5C4WVOVO.js → chunk-P72ZJRSX.js} +3 -3
- package/dist/{chunk-4WI3FU5L.js → chunk-RU2RMTGT.js} +2 -2
- package/dist/{chunk-GYBMMWGF.js → chunk-SAUTJMK6.js} +1 -1
- package/dist/{chunk-JMRESWQT.js → chunk-SWP36NCB.js} +1 -1
- package/dist/{chunk-WFHI6HXP.js → chunk-T4SY3FMN.js} +3 -3
- package/dist/{chunk-6ZB3XNAT.js → chunk-ZRE4ZYEG.js} +1 -1
- package/dist/{chunk-6CUFRMMF.js → chunk-ZSLRAMCK.js} +1 -1
- package/dist/client/index.js +3 -3
- package/dist/commerce/index.js +4 -4
- package/dist/engage/index.js +6 -6
- package/dist/fleet/index.js +4 -4
- package/dist/forms/index.js +7 -7
- package/dist/forms/server.js +2 -2
- package/dist/forms/types.d.ts +3 -1
- package/dist/images/index.js +4 -4
- package/dist/index.js +1 -1
- package/dist/layout/client.js +7 -7
- package/dist/layout/index.js +8 -8
- package/dist/maps/index.js +3 -3
- package/dist/mcp/sonor.js +9 -7
- package/dist/seo/client.js +4 -4
- package/dist/seo/index.js +4 -4
- package/dist/server/index.js +2 -2
- package/dist/shared/version.d.ts +1 -1
- package/dist/signal/index.js +2 -2
- package/dist/sync/index.js +5 -5
- package/dist/website/images.js +4 -4
- package/dist/website/index.js +5 -5
- package/dist/website/popups.js +4 -4
- package/docs/MIGRATING-TO-7.md +146 -0
- package/docs.json +67 -0
- package/package.json +9 -4
- package/src/admin-auth/README.md +88 -0
- package/src/analytics/README.md +264 -0
- package/src/articles/README.md +325 -0
- package/src/commerce/README.md +109 -0
- package/src/cta-bar/README.md +154 -0
- package/src/engage/README.md +241 -0
- package/src/forms/README.md +219 -0
- package/src/images/README.md +74 -0
- package/src/layout/README.md +66 -0
- package/src/llms/README.md +723 -0
- package/src/mcp/README.md +376 -0
- package/src/motion/README.md +372 -0
- package/src/og/README.md +304 -0
- package/src/proxy/README.md +152 -0
- package/src/redirects/README.md +74 -0
- package/src/reputation/README.md +64 -0
- package/src/seo/README.md +359 -0
- package/src/signal/README.md +115 -0
- package/src/sitemap/README.md +127 -0
- package/src/sync/README.md +115 -0
- package/dist/SitemapSync-IKNKPT2G.js +0 -8
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# Engage — `@sonordev/site-kit/engage`
|
|
2
|
+
|
|
3
|
+
Popups, nudges, bars, slide-ins, and chat widgets — all configured from the Sonor dashboard.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Auto-included by `SiteKitLayout`. For standalone use:
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
'use client'
|
|
11
|
+
import { EngageWidget } from '@sonordev/site-kit/engage'
|
|
12
|
+
|
|
13
|
+
export default function Layout({ children }) {
|
|
14
|
+
return (
|
|
15
|
+
<>
|
|
16
|
+
{children}
|
|
17
|
+
<EngageWidget />
|
|
18
|
+
</>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Props
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
interface EngageWidgetProps {
|
|
27
|
+
apiUrl?: string // Default: https://api.sonor.io
|
|
28
|
+
apiKey?: string // From SiteKitLayout or env
|
|
29
|
+
projectId?: string // For chat routing
|
|
30
|
+
position?: 'bottom-right' | 'bottom-left' // Default: 'bottom-right'
|
|
31
|
+
offsetBottom?: string | number // Default: '20px'. See "Launcher placement"
|
|
32
|
+
zIndex?: number // Default: 9999. Popups, nudges, bars and the chat. See "Stacking"
|
|
33
|
+
chatEnabled?: boolean // Default: true. See "The chat switch"
|
|
34
|
+
debug?: boolean
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Through `SiteKitLayout`, the same options go in `engage={{ ... }}`.
|
|
39
|
+
|
|
40
|
+
## The chat switch
|
|
41
|
+
|
|
42
|
+
Echo follows the project's **Enable Chat Widget** switch in Sonor (Engage,
|
|
43
|
+
Chat settings). A project that has never saved chat settings counts as on, so
|
|
44
|
+
Echo is on by default and only an owner who switches it off hides it. It also
|
|
45
|
+
needs the project's **Engage** module on (Project Settings); without it Sonor
|
|
46
|
+
answers off, since the chat has nowhere to take a visitor's message.
|
|
47
|
+
|
|
48
|
+
- The launcher appears once `GET /engage/widget/config` answers. Nothing
|
|
49
|
+
renders before that, so a switched-off site never flashes a launcher, and
|
|
50
|
+
it never starts Echo's availability polling.
|
|
51
|
+
- If the config can't be fetched, the launcher stays hidden. The chat can't
|
|
52
|
+
run without the API anyway.
|
|
53
|
+
- `chatEnabled: false` (or `engage={false}`) in code still turns chat off
|
|
54
|
+
whatever the switch says. Code can turn Echo off; it can't force it on over
|
|
55
|
+
the owner's switch.
|
|
56
|
+
|
|
57
|
+
## Liquid Glass (6.1.0)
|
|
58
|
+
|
|
59
|
+
Echo's launcher and chat window are made of the kit's shared Liquid Glass
|
|
60
|
+
recipe (`src/shared/glass.tsx`), the same material as the mobile CTA bar
|
|
61
|
+
(`@sonordev/site-kit/cta-bar`), so the two always match.
|
|
62
|
+
|
|
63
|
+
- **Launcher:** brand-tinted glass (86% brand over a blurred backdrop) with a
|
|
64
|
+
specular rim. The icon turns dark on a light brand colour; it used to stay
|
|
65
|
+
white and disappear.
|
|
66
|
+
- **Chat window:** a glass panel (86% tint, 28px blur) that grows out of the
|
|
67
|
+
launcher's corner. The header is part of the sheet, washed with the brand
|
|
68
|
+
at the top, and the brand sits on the avatar tile, the visitor's bubbles,
|
|
69
|
+
the send button and the launcher.
|
|
70
|
+
- **Bubbles and the composer stay near-opaque** (94%). The glass is depth,
|
|
71
|
+
never the surface text reads against.
|
|
72
|
+
- **Brand text always reads (6.1.2).** Where the brand is text on the panel
|
|
73
|
+
(quick-action chips, the phone link, link buttons, suggestion chips, "Talk
|
|
74
|
+
to a person"), Echo uses the brand as-is when it clears WCAG AA against the
|
|
75
|
+
panel, and otherwise pulls it toward black (light panel) or white (dark
|
|
76
|
+
panel) just far enough to clear it: `#d4af37` gold becomes `#887023`. Fills
|
|
77
|
+
(launcher, avatar, the visitor's bubbles, buttons) keep the raw brand. One
|
|
78
|
+
helper decides this, `src/engage/brand-color.ts`; route any new brand
|
|
79
|
+
foreground through it. `--sk-primary` can be hex, `rgb()` or `hsl()`.
|
|
80
|
+
- **Fields are 16px.** iOS Safari zooms the whole page into any focused field
|
|
81
|
+
under 16px; the chat input and the inline Echo forms were 13.5-14px.
|
|
82
|
+
- **Fallbacks:** no `backdrop-filter`, reduced transparency, or more contrast
|
|
83
|
+
all get the same surfaces solid. Reduced motion skips the open animation.
|
|
84
|
+
|
|
85
|
+
Tune it with the shared tokens, from your own stylesheet:
|
|
86
|
+
|
|
87
|
+
```css
|
|
88
|
+
:root {
|
|
89
|
+
--sk-glass-panel-opacity: 92%; /* denser chat window (default 86%) */
|
|
90
|
+
--sk-glass-brand-opacity: 100%; /* solid brand launcher (default 86%) */
|
|
91
|
+
--sk-glass-tint: #0b0b0c; /* dark glass; pair with --sk-text-primary */
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`--sk-glass-panel-opacity: 100%` gives the pre-6.1 solid window back, with the
|
|
96
|
+
glass header.
|
|
97
|
+
|
|
98
|
+
## Launcher placement
|
|
99
|
+
|
|
100
|
+
The Echo launcher is a 60px circle, fixed 20px from the side and 20px above
|
|
101
|
+
the bottom edge. Its placement is an inline style, so a stylesheet can't move
|
|
102
|
+
it without `!important`. Don't write that override; declare the offset instead.
|
|
103
|
+
|
|
104
|
+
**A fixed offset, every page:** pass `offsetBottom`.
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
<SiteKitLayout engage={{ offsetBottom: '88px' }}>{children}</SiteKitLayout>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Any CSS length works (`'5.5rem'`, `'calc(4rem + 8px)'`); a number is pixels.
|
|
111
|
+
The device's safe-area inset is added on top, so pass the clearance you want
|
|
112
|
+
above your own UI, not the inset.
|
|
113
|
+
|
|
114
|
+
**An offset that depends on the page or the breakpoint:** set the
|
|
115
|
+
`--sk-echo-offset-bottom` custom property from your stylesheet. The launcher
|
|
116
|
+
is portalled to `<body>`, so a declaration on `body` or `:root` reaches it,
|
|
117
|
+
and the property wins over `offsetBottom`. This clears a sticky mobile bar
|
|
118
|
+
only on the pages that render one:
|
|
119
|
+
|
|
120
|
+
```css
|
|
121
|
+
@media (max-width: 1023.98px) {
|
|
122
|
+
body:has(.sticky-cta) {
|
|
123
|
+
--sk-echo-offset-bottom: 5.5rem;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Pages without the bar, desktop, and any browser without `:has()` keep the
|
|
129
|
+
default. No `!important`, no selector on the kit's markup.
|
|
130
|
+
|
|
131
|
+
**Using the kit's `<CtaBar>`?** Write nothing. It sets
|
|
132
|
+
`--sk-echo-offset-bottom` itself while it's on screen, below its breakpoint,
|
|
133
|
+
and the launcher glides up and back down as the bar shows and hides. Delete
|
|
134
|
+
any rule like the one above that was written for a hand-rolled bar.
|
|
135
|
+
|
|
136
|
+
**The popup follows.** It opens 10px above the launcher and keeps 30px clear
|
|
137
|
+
of the top edge, wherever the offset puts the launcher. (An override that
|
|
138
|
+
moved only the `<button>` left the popup behind, with the launcher over its
|
|
139
|
+
input row.)
|
|
140
|
+
|
|
141
|
+
The resolved position is:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
launcher bottom = offset + env(safe-area-inset-bottom) + var(--sk-vv-layout-gap, 0px)
|
|
145
|
+
popup bottom = launcher bottom + 70px
|
|
146
|
+
popup maxHeight = 100dvh - launcher bottom - 100px
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Stacking
|
|
150
|
+
|
|
151
|
+
`zIndex` is the one layer everything Engage renders sits on: popups, nudges,
|
|
152
|
+
bars and the chat launcher. The chat popup sits one layer beneath the
|
|
153
|
+
launcher. The default is 9999, above almost anything a site draws, so lower it
|
|
154
|
+
when your own fixed UI (a mobile menu, a cookie banner) has to cover the chat:
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
<SiteKitLayout engage={{ zIndex: 40 }}>{children}</SiteKitLayout>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
launcher z-index = zIndex (default 9999)
|
|
162
|
+
popup z-index = zIndex - 1
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
At `zIndex` 0 or below the popup shares the launcher's layer instead, because
|
|
166
|
+
-1 would put it behind the page's own content. The launcher still paints on
|
|
167
|
+
top.
|
|
168
|
+
|
|
169
|
+
### Layout vs visual viewport on phones
|
|
170
|
+
|
|
171
|
+
On a phone the layout viewport can be taller than what the visitor can see
|
|
172
|
+
(browser chrome, in-app browsers, pinch zoom), and `position: fixed` is
|
|
173
|
+
measured against the layout viewport, so a bottom-fixed launcher can sit
|
|
174
|
+
below the fold. Mount `VisualViewportGap` to publish the difference as
|
|
175
|
+
`--sk-vv-layout-gap` on `<html>`. The launcher and popup already read it, and
|
|
176
|
+
your own fixed bottom UI can too:
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
import { VisualViewportGap } from '@sonordev/site-kit/client'
|
|
180
|
+
|
|
181
|
+
<SiteKitLayout>
|
|
182
|
+
<VisualViewportGap />
|
|
183
|
+
{children}
|
|
184
|
+
</SiteKitLayout>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
```css
|
|
188
|
+
.mobile-cta {
|
|
189
|
+
bottom: calc(24px + env(safe-area-inset-bottom, 0px) + var(--sk-vv-layout-gap, 0px));
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
It's opt-in: while a field has focus the gap grows to the keyboard's height,
|
|
194
|
+
so everything that reads it rides above the keyboard. `useVisualViewportGap()`
|
|
195
|
+
is the hook form for an existing client component.
|
|
196
|
+
|
|
197
|
+
## Element Types
|
|
198
|
+
|
|
199
|
+
| Type | Description |
|
|
200
|
+
|------|-------------|
|
|
201
|
+
| `popup` | Modal overlay with CTA |
|
|
202
|
+
| `nudge` | Small corner notification |
|
|
203
|
+
| `bar` | Top/bottom sticky bar |
|
|
204
|
+
| `slide-in` | Side panel |
|
|
205
|
+
| `chat` | AI/live chat widget |
|
|
206
|
+
|
|
207
|
+
## Targeting & Triggers
|
|
208
|
+
|
|
209
|
+
All configured in the Sonor dashboard — no code changes needed:
|
|
210
|
+
|
|
211
|
+
- **Page targeting** — include/exclude paths with wildcard support
|
|
212
|
+
- **Device targeting** — desktop, mobile, tablet
|
|
213
|
+
- **Visitor targeting** — new vs returning visitors
|
|
214
|
+
- **Triggers** — immediate, delay (seconds), scroll (%), exit-intent, click, custom
|
|
215
|
+
- **Frequency capping** — once, once-per-session, every N days
|
|
216
|
+
|
|
217
|
+
## Chat Widget
|
|
218
|
+
|
|
219
|
+
Supports AI mode (Echo), live mode, and hybrid (AI + human handoff):
|
|
220
|
+
|
|
221
|
+
```ts
|
|
222
|
+
interface ChatConfig {
|
|
223
|
+
position: 'bottom-right' | 'bottom-left'
|
|
224
|
+
offsetBottom?: string | number // See "Launcher placement"
|
|
225
|
+
zIndex?: number // Default: 9999. See "Stacking"
|
|
226
|
+
mode: 'ai' | 'live' | 'hybrid'
|
|
227
|
+
buttonColor?: string
|
|
228
|
+
aiSettings?: {
|
|
229
|
+
skillId?: string
|
|
230
|
+
handoffToLive?: boolean
|
|
231
|
+
handoffKeywords?: string[]
|
|
232
|
+
}
|
|
233
|
+
operatingHours?: { ... }
|
|
234
|
+
offlineMode?: 'form' | 'ai' | 'message'
|
|
235
|
+
offlineFormSlug?: string
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Tracking
|
|
240
|
+
|
|
241
|
+
Impressions and clicks are automatically tracked via the Sonor API. Shares visitor ID (`_sk_vid`) with Analytics for cross-module attribution.
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# Forms — `@sonordev/site-kit/forms`
|
|
2
|
+
|
|
3
|
+
Sonor-managed forms with multi-step support, conditional logic, validation, anti-bot protection, and automatic CRM routing.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
### Option 1: Managed (simplest)
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { ManagedForm } from '@sonordev/site-kit/forms'
|
|
11
|
+
|
|
12
|
+
export default function ContactPage() {
|
|
13
|
+
return <ManagedForm formId="contact-form" />
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Fetches form config from Sonor, renders fields, handles submission, routes to CRM.
|
|
18
|
+
|
|
19
|
+
## Experiences (4.0)
|
|
20
|
+
|
|
21
|
+
Since 4.0 that one line gets you the **spotlight** experience by default: the
|
|
22
|
+
familiar layout, alive. A glowing ring visits the field you're in, completed
|
|
23
|
+
fields earn a check, and each finished row collapses into a sentence the form
|
|
24
|
+
says back — "Nice to meet you, Jordan." / "We'll follow up at jordan@…" — with
|
|
25
|
+
an edit control to reopen it.
|
|
26
|
+
|
|
27
|
+
| Experience | What it is | How to get it |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| `spotlight` | **Default.** Fields perform in place; answered rows become sentences | nothing to do |
|
|
30
|
+
| `stage` | Accordion: one beat at a time on a single surface, answered beats settle into filled rows | `experience="stage"` |
|
|
31
|
+
| `classic` | The plain grid form, no choreography | `experience="classic"` |
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
<ManagedForm formId="contact-form" /> // spotlight
|
|
35
|
+
<ManagedForm formId="contact-form" experience="stage" /> // accordion
|
|
36
|
+
<ManagedForm formId="contact-form" experience="classic" /> // opt out
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Sonor can decide instead of the site, with no deploy on either side — set the
|
|
40
|
+
form's `layout` to `classic`, `stage`, or `spotlight`. An explicit
|
|
41
|
+
`experience` prop always wins over the config.
|
|
42
|
+
|
|
43
|
+
Three things hold for every experience:
|
|
44
|
+
|
|
45
|
+
- **The lead is always capturable.** SSR and no-JS render the plain classic
|
|
46
|
+
form; the experience layers on after hydration. If its chunk never arrives,
|
|
47
|
+
the form still works and still submits.
|
|
48
|
+
- **Nobody pays for what they don't use.** Experience code is loaded on
|
|
49
|
+
demand, so a `classic` form downloads none of it.
|
|
50
|
+
- **Same engine.** Identical validation, honeypot, reCAPTCHA, and CRM routing
|
|
51
|
+
— an experience is a rendering, not a fork.
|
|
52
|
+
|
|
53
|
+
### Editing what the form says back
|
|
54
|
+
|
|
55
|
+
The sentence for a row comes from the kit's built-in wording unless you write
|
|
56
|
+
your own in Sonor: set **`completion_message`** on a field (the first answered
|
|
57
|
+
field in the row that has one wins). Tokens:
|
|
58
|
+
|
|
59
|
+
| Token | Resolves to |
|
|
60
|
+
|---|---|
|
|
61
|
+
| `{value}` | this field's answer |
|
|
62
|
+
| `{label}` | this field's label |
|
|
63
|
+
| `{first_name}` | the form's first-name answer, if any |
|
|
64
|
+
| `{any_field_slug}` | that field's answer |
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
Welcome aboard, {first_name}. We'll reach you at {email}.
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Leave it empty to keep the built-in sentence. Unknown or unanswered tokens
|
|
71
|
+
render as nothing — never raw braces.
|
|
72
|
+
|
|
73
|
+
### Option 2: Headless Hook (full UI control)
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
'use client'
|
|
77
|
+
import { useForm } from '@sonordev/site-kit/forms'
|
|
78
|
+
|
|
79
|
+
export function ContactForm() {
|
|
80
|
+
const {
|
|
81
|
+
fields, values, errors, setFieldValue, submit, isSubmitting,
|
|
82
|
+
step, totalSteps, isMultiStep, nextStep, prevStep, isLastStep,
|
|
83
|
+
} = useForm('contact-form')
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<form onSubmit={(e) => { e.preventDefault(); submit() }}>
|
|
87
|
+
{fields.map(field => (
|
|
88
|
+
<div key={field.slug}>
|
|
89
|
+
<label>{field.label}</label>
|
|
90
|
+
<input
|
|
91
|
+
value={String(values[field.slug] || '')}
|
|
92
|
+
onChange={(e) => setFieldValue(field.slug, e.target.value)}
|
|
93
|
+
/>
|
|
94
|
+
{errors[field.slug] && <span className="error">{errors[field.slug]}</span>}
|
|
95
|
+
</div>
|
|
96
|
+
))}
|
|
97
|
+
{isMultiStep && !isLastStep && <button type="button" onClick={nextStep}>Next</button>}
|
|
98
|
+
{isLastStep && <button type="submit" disabled={isSubmitting}>Submit</button>}
|
|
99
|
+
</form>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Option 3: Render Prop
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
<ManagedForm formId="contact-form">
|
|
108
|
+
{({ fields, values, setFieldValue, submit }) => (
|
|
109
|
+
<MyCustomFormUI fields={fields} values={values} onChange={setFieldValue} onSubmit={submit} />
|
|
110
|
+
)}
|
|
111
|
+
</ManagedForm>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Option 4: Programmatic API
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import { formsApi, field, configureFormsApi } from '@sonordev/site-kit/forms'
|
|
118
|
+
|
|
119
|
+
configureFormsApi({ baseUrl: 'https://api.sonor.io', apiKey: 'sonor_...' })
|
|
120
|
+
|
|
121
|
+
const form = await formsApi.create({
|
|
122
|
+
projectId: 'xxx',
|
|
123
|
+
slug: 'newsletter',
|
|
124
|
+
name: 'Newsletter Signup',
|
|
125
|
+
formType: 'newsletter',
|
|
126
|
+
fields: [
|
|
127
|
+
field.email('email', 'Email', { isRequired: true }),
|
|
128
|
+
field.text('name', 'Name'),
|
|
129
|
+
],
|
|
130
|
+
})
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## ManagedForm Props
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
interface ManagedFormProps {
|
|
137
|
+
formId: string // Form slug or ID
|
|
138
|
+
className?: string
|
|
139
|
+
onSuccess?: (submission: FormSubmitResult) => void
|
|
140
|
+
onError?: (error: Error) => void
|
|
141
|
+
children?: (renderProps: UseFormReturn) => ReactNode // Render prop override
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## useForm Return
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
interface UseFormReturn {
|
|
149
|
+
form: ManagedFormConfig | null
|
|
150
|
+
isLoading: boolean
|
|
151
|
+
fetchError: Error | null
|
|
152
|
+
allFields: FormField[]
|
|
153
|
+
fields: FormField[] // Current step's fields
|
|
154
|
+
visibleFields: FormField[] // After conditional logic
|
|
155
|
+
values: Record<string, unknown>
|
|
156
|
+
errors: Record<string, string>
|
|
157
|
+
setFieldValue: (key: string, value: unknown) => void
|
|
158
|
+
step: number
|
|
159
|
+
totalSteps: number
|
|
160
|
+
isMultiStep: boolean
|
|
161
|
+
progress: number // 0-100
|
|
162
|
+
nextStep: () => void
|
|
163
|
+
prevStep: () => void
|
|
164
|
+
goToStep: (n: number) => void
|
|
165
|
+
canGoNext: boolean
|
|
166
|
+
canGoPrev: boolean
|
|
167
|
+
isLastStep: boolean
|
|
168
|
+
validate: () => boolean
|
|
169
|
+
submit: () => Promise<void>
|
|
170
|
+
isSubmitting: boolean
|
|
171
|
+
isComplete: boolean
|
|
172
|
+
reset: () => void
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Field Types
|
|
177
|
+
|
|
178
|
+
`text`, `email`, `phone`, `tel`, `number`, `textarea`, `select`, `multi-select`, `checkbox`, `radio`, `date`, `time`, `datetime`, `file`, `signature`, `rating`, `slider`, `hidden`, `heading`, `section_header`, `paragraph`
|
|
179
|
+
|
|
180
|
+
## Field Builder
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
field.text(slug, label, options?)
|
|
184
|
+
field.email(slug, label, options?)
|
|
185
|
+
field.phone(slug, label, options?)
|
|
186
|
+
field.textarea(slug, label, options?)
|
|
187
|
+
field.select(slug, label, { options: [{ value, label }] })
|
|
188
|
+
field.date(slug, label, options?)
|
|
189
|
+
field.checkbox(slug, label, options?)
|
|
190
|
+
field.rating(slug, label, options?)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Form Routing
|
|
194
|
+
|
|
195
|
+
Submissions auto-route based on `form_type`:
|
|
196
|
+
|
|
197
|
+
| Form Type | Routes To | Use Case |
|
|
198
|
+
|-----------|-----------|----------|
|
|
199
|
+
| `prospect` / `lead-capture` / `contact` | CRM Contacts | Sales inquiries, quotes |
|
|
200
|
+
| `support` | Support Tickets | Help requests |
|
|
201
|
+
| `feedback` | Feedback entries | User feedback |
|
|
202
|
+
| `newsletter` | Email Subscribers | Newsletter signups |
|
|
203
|
+
| `custom` | Form Submissions only | Custom handling |
|
|
204
|
+
|
|
205
|
+
## Anti-Bot Protection
|
|
206
|
+
|
|
207
|
+
- **Honeypot fields** — hidden fields that bots fill (server-side rejection)
|
|
208
|
+
- **reCAPTCHA Enterprise** — optional Google reCAPTCHA v3 scoring
|
|
209
|
+
- **Submission timing** — forms that submit in < 3 seconds are flagged
|
|
210
|
+
- **Composite spam scoring** — name patterns, email domain, user-agent, IP rate, message content
|
|
211
|
+
- **NestJS ThrottlerGuard** — 10 requests/minute per IP at HTTP level
|
|
212
|
+
|
|
213
|
+
## Styles
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
import '@sonordev/site-kit/forms/styles.css' // Optional default styles
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
All components use `.sk-form__*` class names. Override with `className` prop or CSS variables.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Images — `@sonordev/site-kit/images`
|
|
2
|
+
|
|
3
|
+
Sonor-managed image slots with dev-mode editing, focal point support, and image picker.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { ManagedImage } from '@sonordev/site-kit/images'
|
|
9
|
+
|
|
10
|
+
export default function HeroSection() {
|
|
11
|
+
return (
|
|
12
|
+
<ManagedImage
|
|
13
|
+
slotId="hero-background"
|
|
14
|
+
alt="Hero background"
|
|
15
|
+
width={1920}
|
|
16
|
+
height={1080}
|
|
17
|
+
objectFit="cover"
|
|
18
|
+
fallback="/images/default-hero.jpg"
|
|
19
|
+
/>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Props
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
interface ManagedImageProps {
|
|
28
|
+
slotId: string // Unique slot identifier (e.g., 'hero-background')
|
|
29
|
+
pagePath?: string // Page-specific slots (defaults to current path)
|
|
30
|
+
alt?: string // Fallback alt text
|
|
31
|
+
className?: string
|
|
32
|
+
width?: number | string
|
|
33
|
+
height?: number | string
|
|
34
|
+
objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down'
|
|
35
|
+
fallback?: string // Fallback image URL when slot is empty
|
|
36
|
+
placeholder?: React.ReactNode // Custom placeholder component
|
|
37
|
+
onLoad?: () => void
|
|
38
|
+
onError?: (error: Error) => void
|
|
39
|
+
priority?: boolean // Eager loading (Next.js Image priority)
|
|
40
|
+
style?: React.CSSProperties
|
|
41
|
+
forceDevMode?: boolean // Enable dev picker outside localhost
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Dev Mode
|
|
46
|
+
|
|
47
|
+
Dev mode is on when `NODE_ENV` is `development`, on `localhost` / `127.0.0.1`, on any host with `?sonor_dev=true` in the URL, or with `forceDevMode`:
|
|
48
|
+
- Click any `ManagedImage` to open the image picker modal
|
|
49
|
+
- Browse files by folder, search, upload new images
|
|
50
|
+
- Set alt text and focal point
|
|
51
|
+
- Shows slot ID in empty states for debugging
|
|
52
|
+
|
|
53
|
+
## Focal Point
|
|
54
|
+
|
|
55
|
+
When an image has `focal_point_x` / `focal_point_y` set in Sonor, the component auto-calculates `object-position` so the focal area stays visible during cropping.
|
|
56
|
+
|
|
57
|
+
## API Functions
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { fetchManagedImage, uploadImage, assignImageToSlot } from '@sonordev/site-kit/images'
|
|
61
|
+
|
|
62
|
+
const image = await fetchManagedImage(slotId, pagePath)
|
|
63
|
+
const uploaded = await uploadImage(file, { folder: 'heroes', category: 'background' })
|
|
64
|
+
await assignImageToSlot(slotId, uploaded.id, pagePath)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Favicon
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import { ManagedFavicon } from '@sonordev/site-kit/images'
|
|
71
|
+
|
|
72
|
+
// In layout <head>:
|
|
73
|
+
<ManagedFavicon /> // Fetches Sonor logo as favicon link tags
|
|
74
|
+
```
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Layout — `@sonordev/site-kit/layout`
|
|
2
|
+
|
|
3
|
+
RSC-compatible master layout that auto-composes all site-kit features.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
// app/layout.tsx
|
|
9
|
+
import { SiteKitLayout } from '@sonordev/site-kit/layout'
|
|
10
|
+
|
|
11
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
12
|
+
return (
|
|
13
|
+
<html lang="en">
|
|
14
|
+
<body>
|
|
15
|
+
<SiteKitLayout>{children}</SiteKitLayout>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Zero-config: reads `SONOR_API_KEY` from env, injects it into client modules automatically.
|
|
23
|
+
|
|
24
|
+
## Props
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
interface SiteKitLayoutProps {
|
|
28
|
+
children: React.ReactNode
|
|
29
|
+
apiKey?: string // Defaults to SONOR_API_KEY env var
|
|
30
|
+
apiUrl?: string // Defaults to SONOR_API_URL, then https://api.sonor.io
|
|
31
|
+
projectId?: string // For Engage chat routing (auto-resolved if omitted)
|
|
32
|
+
analytics?: boolean | AnalyticsConfig // Default: true
|
|
33
|
+
engage?: boolean | EngageConfig // Default: true
|
|
34
|
+
signal?: boolean | SignalConfig // Default: false
|
|
35
|
+
sitemapSync?: boolean // Default: false (build-time + server reconciler own this)
|
|
36
|
+
fleet?: boolean // Default: true (once-per-session kit version heartbeat)
|
|
37
|
+
defer?: boolean // Default: true (client modules wait for load + idle)
|
|
38
|
+
favicon?: boolean // Default: true
|
|
39
|
+
managedScripts?: boolean // Default: true
|
|
40
|
+
debug?: boolean // Default: false
|
|
41
|
+
showLlmsTxtFooterLink?: boolean // Default: false (prefer middleware discovery headers)
|
|
42
|
+
speculation?: boolean | { mode?: 'prerender' | 'prefetch'; exclude?: string[] } // Default: false
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Module options live with each module: [Analytics](../analytics/README.md) (`trackPageViews`, `excludePaths`, `site`, `allowInFrame`, `allowLocalhost`) and [Engage](../engage/README.md) (`position`, `chatEnabled`, and launcher placement).
|
|
47
|
+
|
|
48
|
+
## What It Composes
|
|
49
|
+
|
|
50
|
+
**Server-side (RSC):**
|
|
51
|
+
- `ManagedFavicon` — Sonor logo as `<link>` tags
|
|
52
|
+
- `ManagedScripts` — tracking pixels/analytics tags in `<head>` and body-end positions
|
|
53
|
+
- API preconnect/dns-prefetch hints
|
|
54
|
+
|
|
55
|
+
**Client-side (lazy-loaded island):**
|
|
56
|
+
- `AnalyticsProvider` — page views, scroll depth, heatmap clicks, Web Vitals
|
|
57
|
+
- `EngageWidget` — popups, nudges, chat
|
|
58
|
+
- `SignalBridge` — A/B experiments, behavior tracking (opt-in)
|
|
59
|
+
- `SitemapSync` — parses `/sitemap.xml` and syncs to Sonor (opt-in)
|
|
60
|
+
- `FleetHeartbeat` — reports the kit version and enabled modules once per session
|
|
61
|
+
|
|
62
|
+
Since 4.0.0 none of these wrap your page. `{children}` renders first and every module mounts after it as a childless sibling, so `SiteKitLayout` never pushes a route to client rendering. Analytics, Engage, SitemapSync and the heartbeat also wait for window load + idle (or the first interaction) unless you pass `defer={false}`. `SignalBridge` isn't deferred, so experiment variants apply early. Visitor and session IDs come from a shared storage singleton rather than a provider.
|
|
63
|
+
|
|
64
|
+
## Note
|
|
65
|
+
|
|
66
|
+
`SiteKitProvider` was **removed in 4.0.0**. It wrapped the whole tree client-side, which broke RSC. Migrate an older layout with `npx sonor-setup codemod --only provider-to-layout --write`.
|