@usefillo/react 0.8.0 → 0.10.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 CHANGED
@@ -1,9 +1,23 @@
1
- # @usefillo/react
1
+ <p align="center">
2
+ <a href="https://fillo.so">
3
+ <img src="https://fillo.so/brand/readme-banner.png" alt="Fillo — forms inside your product, with your UI." />
4
+ </a>
5
+ </p>
6
+
7
+ <p align="center">
8
+ <a href="https://fillo.so/docs">Docs</a> ·
9
+ <a href="https://fillo.so/guides">Guides</a> ·
10
+ <a href="https://fillo.so/examples">Examples</a> ·
11
+ <a href="https://fillo.so/changelog">Changelog</a>
12
+ </p>
13
+
14
+ <p align="center">
15
+ <a href="https://www.npmjs.com/package/@usefillo/react"><img src="https://img.shields.io/npm/v/@usefillo/react" alt="npm version" /></a>
16
+ <img src="https://img.shields.io/npm/l/@usefillo/react" alt="MIT license" />
17
+ </p>
2
18
 
3
19
  React components and hooks for embedding [Fillo](https://fillo.so) forms **natively inside your product** — rendered in your own DOM, with your styles, on your route. No iframe.
4
20
 
5
- ### 📚 Full documentation → **[fillo.so/docs](https://fillo.so/docs)**
6
-
7
21
  ```sh
8
22
  npm i @usefillo/react
9
23
  ```
@@ -36,10 +50,10 @@ export function ContactForm() {
36
50
  ```
37
51
 
38
52
  The first time this runs, the form appears in your Fillo workspace as a draft —
39
- publish it there and responses, logic, exports, webhooks, and integrations all
40
- work. Field ids are permanent (they key your responses); conditional questions
41
- are `visibleIf`, never conditional JSX. The equivalent config style,
42
- `defineForm({ id, pages })`, remains first-class — JSX compiles to it exactly.
53
+ publish it there and responses, exports, webhooks, and integrations all work.
54
+ Prefer config over JSX? `defineForm({ id, pages })` is first-class — JSX
55
+ compiles to it exactly. Authoring guide:
56
+ [fillo.so/docs/authoring](https://fillo.so/docs/authoring).
43
57
 
44
58
  ## Or embed a form built in the dashboard
45
59
 
@@ -67,12 +81,9 @@ import { FilloForm } from "@usefillo/react";
67
81
  >
68
82
  ```
69
83
 
70
- Every rendered part carries a named slot (`data-fillo`) and state attributes
71
- (`data-invalid`, `data-selected`, `data-checked`, …), and the default
72
- stylesheet is cascade-layered so your utilities always win. On Tailwind v3 or
73
- reset-heavy sites import `@usefillo/react/styles.unlayered.css` instead.
74
- Localize the shared form chrome (navigation, submit states, errors, and resume
75
- notices) with the `strings` prop. Styling contract:
84
+ Every rendered part carries a named slot and state attributes
85
+ (`data-invalid`, `data-selected`, …), and the default stylesheet is
86
+ cascade-layered so your utilities always win. Styling contract:
76
87
  [fillo.so/docs/styling](https://fillo.so/docs/styling).
77
88
 
78
89
  ## Go fully headless
@@ -83,11 +94,7 @@ Every part is replaceable — and every embed method is free:
83
94
  - `<FilloProvider>` + `<FormField>` / `useField()` — your layout, Fillo's engine
84
95
  - `useFilloController()` — the bare engine for total control
85
96
 
86
- URL prefill works in embeds (`?field=value`, hidden-field `paramName`),
87
- submissions retry safely, and failed submits show a visible, answer-preserving
88
- error. This package re-exports the embedding surface from
89
- [`@usefillo/core`](https://www.npmjs.com/package/@usefillo/core) so a single
90
- import is usually enough.
97
+ Headless guide: [fillo.so/docs/custom-ui](https://fillo.so/docs/custom-ui).
91
98
 
92
99
  ## Links
93
100
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentType, ReactNode, ReactElement } from 'react';
3
3
  import * as _usefillo_core from '@usefillo/core';
4
- import { FormSchema, FilloClient, ResponseData, FieldValue, FormPage, Block, FormStatus, FieldKind, Field, CustomField, FormTheme, FilloAppearance, FilloRendererStrings, FilloRespondent, FilloError, CodeForm, FormSettings, Condition, TextField, PhoneField, NumberField, ChoiceField, SelectOption, CheckboxField, RatingField, LinearScaleField, RankingField, SignatureField, DateField, FileUploadField as FileUploadField$1, HiddenField } from '@usefillo/core';
4
+ import { FormSchema, FilloClient, ResponseData, FieldValue, FormPage, Block, FormStatus, FieldKind, Field, CustomField, FormTheme, FilloAppearance, FilloRendererStrings, FilloRespondent, ChallengeConfig, FilloError, CodeForm, FormSettings, Condition, TextField, PhoneField, NumberField, ChoiceField, SelectOption, CheckboxField, RatingField, LinearScaleField, RankingField, SignatureField, DateField, FileUploadField as FileUploadField$1, HiddenField } from '@usefillo/core';
5
5
  export { CodeForm, Field, FieldValue, FileValue, FilloAppearance, FilloClient, FilloError, FilloJsxError, FilloRendererStrings, FilloSlot, FilloStrings, FormSchema, FormStatus, FormTheme, ProvisionWorkspaceResult, PublishedForm, ResponseData, SlotState, createClient, defineForm, provisionWorkspace, when } from '@usefillo/core';
6
6
 
7
7
  /**
@@ -136,10 +136,32 @@ interface FilloFormBaseProps {
136
136
  * loads).
137
137
  */
138
138
  respondent?: FilloRespondent;
139
+ /**
140
+ * Human-verification challenge config (public site key + provider). Normally
141
+ * the SDK reads this from the form fetch automatically; pass it explicitly
142
+ * only when you render an inline `form` schema and still want the widget (the
143
+ * hosted page does this). The SECRET key stays server-side — never passed here.
144
+ */
145
+ challenge?: ChallengeConfig;
139
146
  onChange?: (data: ResponseData) => void;
140
147
  onSubmitted?: (responseId: string | undefined, data: ResponseData) => void;
141
148
  /** Observe load and code-form sync failures (otherwise only logged). */
142
149
  onError?: (error: FilloError) => void;
150
+ /**
151
+ * Show the developer chrome on a surface Fillo doesn't detect as local
152
+ * development — a tunnel, a staging deploy, a production build you're
153
+ * smoke-testing. COSMETIC ONLY: it renders the dev notices, developer-grade
154
+ * submit failures, and a visible "Preview" badge, and it never changes
155
+ * where submissions go or whether they are accepted (test submissions
156
+ * authenticate with a credential, never a prop).
157
+ */
158
+ preview?: boolean;
159
+ /**
160
+ * Set false to hide the built-in dev notices (draft/staged/sync/no-client)
161
+ * when your page provides its own context. The explicit Preview badge and
162
+ * the production fail-closed states are unaffected.
163
+ */
164
+ devNotices?: boolean;
143
165
  /**
144
166
  * Render the form's own title/description header (default true). Set false
145
167
  * when the embedding page already provides a heading, to avoid a second
@@ -280,12 +302,25 @@ interface ControllerOptions {
280
302
  surface?: "default" | "headless";
281
303
  /** Resolve/verify the canonical submission target immediately before submit. */
282
304
  resolveFormId?: () => Promise<string>;
305
+ /**
306
+ * Surface the real resolveFormId failure (message + machine code) in
307
+ * `submitError` instead of the respondent-safe fallback. The built-in
308
+ * renderers set it from their dev-chrome gate (preview prop / dev
309
+ * environment) so integration details never reach production visitors.
310
+ */
311
+ verboseResolutionErrors?: boolean;
283
312
  /**
284
313
  * Host-app account context (identify()): who is filling this form, by your
285
314
  * own user id. Recorded with the response as an unverified claim so the
286
315
  * dashboard, webhooks, and integrations can say who answered.
287
316
  */
288
317
  respondent?: FilloRespondent;
318
+ /** True when the form requires a human-verification challenge (Turnstile). */
319
+ challengeRequired?: boolean;
320
+ /** Read the current challenge token from the rendered widget (lazy). */
321
+ getChallengeToken?: () => string | undefined;
322
+ /** The server rejected the challenge — reset the widget for a fresh token. */
323
+ onChallengeFailed?: () => void;
289
324
  }
290
325
  /**
291
326
  * React binding for the framework-agnostic engine in @usefillo/core
@@ -308,6 +343,15 @@ interface FilloProviderProps extends Omit<ControllerOptions, "form"> {
308
343
  onError?: (error: FilloError) => void;
309
344
  /** Custom unavailable state; receives the full actionable integration error. */
310
345
  renderError?: (error: FilloError) => ReactNode;
346
+ /**
347
+ * Apply the developer-chrome behavior on a surface Fillo doesn't detect as
348
+ * local development (a tunnel, staging, a production smoke test): the code
349
+ * form renders and gates like development and failed submits carry the real
350
+ * error + code. COSMETIC ONLY — it never changes where submissions go or
351
+ * whether they are accepted. Headless stays headless: the provider still
352
+ * injects no layout (no badge or notices); the host owns all preview UI.
353
+ */
354
+ preview?: boolean;
311
355
  children: ReactNode;
312
356
  }
313
357
  /**
@@ -330,7 +374,7 @@ interface FilloProviderProps extends Omit<ControllerOptions, "form"> {
330
374
  * defineForm() form and a keyed client, the structure also syncs into your
331
375
  * workspace, exactly like <FilloForm>.
332
376
  */
333
- declare function FilloProvider({ children, form, formId, client, appearance, strings, onError, renderError, ...options }: FilloProviderProps): react.JSX.Element | null;
377
+ declare function FilloProvider({ children, form, formId, client, appearance, strings, onError, renderError, preview, ...options }: FilloProviderProps): react.JSX.Element | null;
334
378
 
335
379
  /**
336
380
  * The full form engine — data, errors, pages, submit, status. Use inside a