@usefillo/react 0.3.1 → 0.4.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 +8 -4
- package/dist/index.d.ts +37 -17
- package/dist/index.js +715 -309
- package/dist/styles.css +220 -14
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,13 +11,11 @@ npm i @usefillo/react
|
|
|
11
11
|
`react` and `react-dom` (18 or 19) are peer dependencies.
|
|
12
12
|
|
|
13
13
|
```tsx
|
|
14
|
-
import { FilloForm
|
|
14
|
+
import { FilloForm } from "@usefillo/react";
|
|
15
15
|
import "@usefillo/react/styles.css"; // optional default theme — or bring your own
|
|
16
16
|
|
|
17
|
-
const client = createClient({ key: "pk_live_…" });
|
|
18
|
-
|
|
19
17
|
export function Feedback() {
|
|
20
|
-
return <FilloForm
|
|
18
|
+
return <FilloForm formId="cust-feedback" onSubmitted={(r) => confetti()} />;
|
|
21
19
|
}
|
|
22
20
|
```
|
|
23
21
|
|
|
@@ -29,6 +27,12 @@ Every part is replaceable. Pass your own field components, theme the form via th
|
|
|
29
27
|
- `FormField` / `BlockRenderer` — render individual blocks
|
|
30
28
|
- `defineForm()` — author a form in code and sync it to your workspace on first run
|
|
31
29
|
|
|
30
|
+
Published `formId` embeds can fetch and submit without a publishable key. Use `createClient({ key })` when syncing `defineForm()` schemas from code, or when you need to point the SDK at a custom API origin.
|
|
31
|
+
|
|
32
|
+
For tiny feedback widgets, set `settings.submitMode: "auto"` on a select/rating/checkbox/dropdown/linear scale form. The default renderer hides the first submit button, submits after a complete discrete answer, and brings the submit button back if that answer opens a text or upload follow-up. Add `submissionLimit: "once_per_visitor"` for browser-scoped one-response feedback.
|
|
33
|
+
|
|
34
|
+
The default stylesheet follows system dark mode for unthemed embeds. Pass `theme={{ colorScheme: "dark" }}` or `"light"` when the host surface is known.
|
|
35
|
+
|
|
32
36
|
This package re-exports the embedding surface from [`@usefillo/core`](https://www.npmjs.com/package/@usefillo/core) (`createClient`, `FormSchema`, `FormTheme`, …) so a single import is usually enough.
|
|
33
37
|
|
|
34
38
|
## Links
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ComponentType, ReactNode } from 'react';
|
|
3
|
-
import { FormSchema, FilloClient, ResponseData, FieldValue, FormPage, Block, FormStatus, FieldKind, Field,
|
|
3
|
+
import { FormSchema, FilloClient, ResponseData, FieldValue, FormPage, Block, FormStatus, FieldKind, Field, FormTheme, FilloError, CodeForm } from '@usefillo/core';
|
|
4
4
|
export { CodeForm, Field, FieldValue, FileValue, FilloClient, FilloError, FormSchema, FormStatus, FormTheme, ProvisionWorkspaceResult, PublishedForm, ResponseData, createClient, defineForm, provisionWorkspace } from '@usefillo/core';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -30,12 +30,20 @@ interface FilloApi {
|
|
|
30
30
|
/** Used by upload fields to gate submission. */
|
|
31
31
|
setUploading: (fieldId: string, busy: boolean) => void;
|
|
32
32
|
}
|
|
33
|
+
interface FilloFieldIds {
|
|
34
|
+
inputId: string;
|
|
35
|
+
labelId: string;
|
|
36
|
+
descriptionId: string;
|
|
37
|
+
errorId: string;
|
|
38
|
+
name: string;
|
|
39
|
+
}
|
|
33
40
|
interface FieldComponentProps {
|
|
34
41
|
field: Field;
|
|
35
42
|
value: FieldValue;
|
|
36
43
|
error: string | undefined;
|
|
37
44
|
setValue: (value: FieldValue) => void;
|
|
38
45
|
api: FilloApi;
|
|
46
|
+
ids?: FilloFieldIds;
|
|
39
47
|
}
|
|
40
48
|
/** Per-kind component overrides — swap any built-in field for your own. */
|
|
41
49
|
type FieldComponents = Partial<Record<FieldKind, ComponentType<FieldComponentProps>>>;
|
|
@@ -46,12 +54,7 @@ type FieldComponents = Partial<Record<FieldKind, ComponentType<FieldComponentPro
|
|
|
46
54
|
*/
|
|
47
55
|
type CustomComponents = Record<string, ComponentType<FieldComponentProps>>;
|
|
48
56
|
|
|
49
|
-
interface
|
|
50
|
-
/** Render a schema directly, or a code-defined form from defineForm(). */
|
|
51
|
-
form?: FormSchema | CodeForm;
|
|
52
|
-
/** Or fetch it: a client plus the form id/slug. */
|
|
53
|
-
client?: FilloClient;
|
|
54
|
-
formId?: string;
|
|
57
|
+
interface FilloFormBaseProps {
|
|
55
58
|
theme?: FormTheme;
|
|
56
59
|
/** Swap any built-in field kind for your own component. */
|
|
57
60
|
components?: FieldComponents;
|
|
@@ -72,17 +75,34 @@ interface FilloFormProps {
|
|
|
72
75
|
renderSuccess?: () => ReactNode;
|
|
73
76
|
/** Custom error screen — receives the failure (e.g. 404 vs network). */
|
|
74
77
|
renderError?: (error: FilloError) => ReactNode;
|
|
75
|
-
/** Let "Next" move between pages without validating — for builder previews. */
|
|
76
|
-
skipValidation?: boolean;
|
|
77
78
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* Removing the badge on a free workspace violates the Fillo terms. Builder
|
|
81
|
-
* previews (`skipValidation`) never show it.
|
|
79
|
+
* @internal Builder/test preview: let "Next" move between pages without
|
|
80
|
+
* client-side validation. Submission and branding are still authoritative.
|
|
82
81
|
*/
|
|
83
|
-
|
|
82
|
+
skipValidation?: boolean;
|
|
84
83
|
className?: string;
|
|
85
84
|
}
|
|
85
|
+
type HostedFormProps = FilloFormBaseProps & {
|
|
86
|
+
/** Fetch a published form by id/slug. A default Fillo client is created if omitted. */
|
|
87
|
+
formId: string;
|
|
88
|
+
form?: undefined;
|
|
89
|
+
client?: FilloClient;
|
|
90
|
+
};
|
|
91
|
+
type CodeBackedFormProps = FilloFormBaseProps & {
|
|
92
|
+
/** Render a schema directly, or a code-defined form from defineForm(). */
|
|
93
|
+
form: FormSchema | CodeForm;
|
|
94
|
+
/** Required for code-defined forms that should save responses in Fillo. */
|
|
95
|
+
client: FilloClient;
|
|
96
|
+
formId?: string;
|
|
97
|
+
};
|
|
98
|
+
type PreviewFormProps = FilloFormBaseProps & {
|
|
99
|
+
/** Builder/test preview: render locally and complete locally. */
|
|
100
|
+
form: FormSchema | CodeForm;
|
|
101
|
+
client?: FilloClient;
|
|
102
|
+
formId?: string;
|
|
103
|
+
skipValidation: true;
|
|
104
|
+
};
|
|
105
|
+
type FilloFormProps = HostedFormProps | CodeBackedFormProps | PreviewFormProps;
|
|
86
106
|
declare function FilloForm(props: FilloFormProps): react.JSX.Element;
|
|
87
107
|
|
|
88
108
|
interface ControllerOptions {
|
|
@@ -94,7 +114,7 @@ interface ControllerOptions {
|
|
|
94
114
|
onSubmitted?: (responseId: string | undefined, data: ResponseData) => void;
|
|
95
115
|
/** Anti-spam signals provided by the renderer (honeypot value). */
|
|
96
116
|
getHoneypot?: () => string;
|
|
97
|
-
/**
|
|
117
|
+
/** @internal Preview-only page navigation escape hatch. Submission still validates. */
|
|
98
118
|
skipValidation?: boolean;
|
|
99
119
|
/** Embedding surface; "headless" (FilloProvider) is server-enforced as paid. */
|
|
100
120
|
surface?: "default" | "headless";
|
|
@@ -176,6 +196,6 @@ declare function FormField({ id, components, customComponents, }: {
|
|
|
176
196
|
* progress, multiple files. Replace it entirely via the `components` prop if
|
|
177
197
|
* you want your own — completed uploads are just FileValue[] in the data.
|
|
178
198
|
*/
|
|
179
|
-
declare function FileUploadField({ field, value, error, setValue, api }: FieldComponentProps): react.JSX.Element;
|
|
199
|
+
declare function FileUploadField({ field, value, error, setValue, api, ids: providedIds }: FieldComponentProps): react.JSX.Element;
|
|
180
200
|
|
|
181
|
-
export { BlockRenderer, type ControllerOptions, type CustomComponents, type FieldComponentProps, type FieldComponents, type FieldHandle, type FilloApi, FileUploadField as FilloFileUpload, FilloForm, type FilloFormProps, FilloProvider, type FilloProviderProps, FormField, useField, useFillo, useFilloController };
|
|
201
|
+
export { BlockRenderer, type ControllerOptions, type CustomComponents, type FieldComponentProps, type FieldComponents, type FieldHandle, type FilloApi, type FilloFieldIds, FileUploadField as FilloFileUpload, FilloForm, type FilloFormProps, FilloProvider, type FilloProviderProps, FormField, useField, useFillo, useFilloController };
|