@leadbot/components 2.21.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 +332 -0
- package/dist/agentChat.d.ts +45 -0
- package/dist/agentChat.d.ts.map +1 -0
- package/dist/buttons.d.ts +42 -0
- package/dist/buttons.d.ts.map +1 -0
- package/dist/flow.d.ts +41 -0
- package/dist/flow.d.ts.map +1 -0
- package/dist/form.d.ts +63 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6779 -0
- package/dist/mount.d.ts +88 -0
- package/dist/mount.d.ts.map +1 -0
- package/dist/styles.css +2723 -0
- package/dist/useStep.d.ts +20 -0
- package/dist/useStep.d.ts.map +1 -0
- package/dist/whatsapp.d.ts +28 -0
- package/dist/whatsapp.d.ts.map +1 -0
- package/package.json +41 -0
package/dist/mount.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type ComponentType } from "preact";
|
|
2
|
+
import { type LeadbotClient } from "@leadbot/core";
|
|
3
|
+
export interface LeadbotComponentsConfig {
|
|
4
|
+
domainKey?: string;
|
|
5
|
+
/** API server origin, e.g. "https://collector.example.com" — "/api" is appended. */
|
|
6
|
+
apiHost?: string;
|
|
7
|
+
/** Id of the component leadbot these components belong to (dashboard → Settings → Components). */
|
|
8
|
+
leadbotId?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Page path sent to the collector; defaults to location.pathname. The boot
|
|
11
|
+
* fetch also reads `<html lang>`, so outside a browser pass `language` too
|
|
12
|
+
* — path alone still touches `document`.
|
|
13
|
+
*/
|
|
14
|
+
path?: string;
|
|
15
|
+
/** Page language sent to the collector; defaults to the `<html lang>` attribute. */
|
|
16
|
+
language?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Dashboard preview token, authorizing the unpublished draft flow. Only
|
|
19
|
+
* honoured together with `preview: true`. Dashboard preview only — never
|
|
20
|
+
* commit one into a production build: it grants read access to draft flows
|
|
21
|
+
* to anyone reading the shipped JS.
|
|
22
|
+
*/
|
|
23
|
+
previewToken?: string;
|
|
24
|
+
/** Base/primary color for buttons etc. — sets --leadbot-primary on the mount. */
|
|
25
|
+
baseColor?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Test/preview mode. Submissions and chat turns run end-to-end (AI still
|
|
28
|
+
* responds) but the collector does not persist them to the inbox. Used by
|
|
29
|
+
* the dashboard preview so test interactions never create real leads.
|
|
30
|
+
*/
|
|
31
|
+
preview?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Set module-level defaults; every mount accepts the same keys as overrides.
|
|
35
|
+
* With a domain key and a leadbot id it also runs the boot fetch right away,
|
|
36
|
+
* so the pageview is billed even on pages that mount no components.
|
|
37
|
+
*
|
|
38
|
+
* Note: without a `leadbotId` there is no boot fetch, so `applyFlowGates`
|
|
39
|
+
* never runs — a first-ever visit to such a page stays dark and no GA events
|
|
40
|
+
* fire. Pass the leadbot id to get the same tracking as the classic widget.
|
|
41
|
+
*/
|
|
42
|
+
export declare function init(config: LeadbotComponentsConfig): void;
|
|
43
|
+
/** Merge the `init()` defaults under explicitly-set option keys. */
|
|
44
|
+
export declare function withDefaults(options: LeadbotComponentsConfig): LeadbotComponentsConfig;
|
|
45
|
+
export declare function resolveClient(options: LeadbotComponentsConfig): LeadbotClient;
|
|
46
|
+
/**
|
|
47
|
+
* Boot fetch of the published flow: delivers the steps and bills the pageview.
|
|
48
|
+
* Bumps the generation, so a response for a route the caller has already left
|
|
49
|
+
* loses the race and never arms tracking with the stale bot's gates.
|
|
50
|
+
*/
|
|
51
|
+
export declare function loadFlow(options: LeadbotComponentsConfig): Promise<import("@leadbot/core").LeadBotConfig | null>;
|
|
52
|
+
/**
|
|
53
|
+
* Preview fields for submit/chat calls and the boot fetch, falling back to the
|
|
54
|
+
* `init()` defaults — without the token the collector rejects draft steps as
|
|
55
|
+
* unpublished. The token is dropped unless `preview` is set, so one accidentally
|
|
56
|
+
* hardcoded into a shipped bundle cannot read draft flows on its own.
|
|
57
|
+
*/
|
|
58
|
+
export declare function previewOptions(options: LeadbotComponentsConfig): Pick<LeadbotComponentsConfig, "preview" | "previewToken">;
|
|
59
|
+
export interface BaseMountOptions extends LeadbotComponentsConfig {
|
|
60
|
+
/** Extra class name(s) added to the mount container. */
|
|
61
|
+
className?: string;
|
|
62
|
+
/**
|
|
63
|
+
* `false` drops the widget chrome — card surface, size caps, scroll region,
|
|
64
|
+
* and the form's actions bar — leaving only functional styling (field
|
|
65
|
+
* stacking, focus rings, error states) inside your own layout.
|
|
66
|
+
*/
|
|
67
|
+
chrome?: boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface MountHandle<O> {
|
|
70
|
+
update(options: Partial<O>): void;
|
|
71
|
+
destroy(): void;
|
|
72
|
+
}
|
|
73
|
+
/** Styling root: every rule in `@leadbot/components/styles.css` is scoped to it. */
|
|
74
|
+
export declare const ROOT_CLASS = "leadbot-components";
|
|
75
|
+
/** Added next to ROOT_CLASS when a mount opts out of the widget chrome. */
|
|
76
|
+
export declare const BARE_CLASS = "leadbot-bare";
|
|
77
|
+
/**
|
|
78
|
+
* Render a Preact component into `el` (light DOM) and return an imperative
|
|
79
|
+
* handle. `update()` shallow-merges options and re-renders in place, so
|
|
80
|
+
* component state (chat history, form values) survives updates.
|
|
81
|
+
*/
|
|
82
|
+
export declare function createMount<O extends BaseMountOptions>(Component: ComponentType<O>, el: HTMLElement, options: O): MountHandle<O>;
|
|
83
|
+
/**
|
|
84
|
+
* Analytics context sent with component submissions and chat turns — the same
|
|
85
|
+
* builder the classic widget uses, so both produce identical fields.
|
|
86
|
+
*/
|
|
87
|
+
export { buildAnalytics } from "@leadbot/core";
|
|
88
|
+
//# sourceMappingURL=mount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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