@usefillo/react 0.5.3 → 0.6.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/dist/index.d.ts +120 -9
- package/dist/index.js +585 -155
- package/dist/styles.css +26 -13
- package/dist/styles.unlayered.css +700 -0
- package/package.json +10 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ComponentType, ReactNode } from 'react';
|
|
3
|
-
import
|
|
4
|
-
|
|
2
|
+
import { ComponentType, ReactNode, ReactElement } from 'react';
|
|
3
|
+
import * as _usefillo_core from '@usefillo/core';
|
|
4
|
+
import { FormSchema, FilloClient, ResponseData, FieldValue, FormPage, Block, FormStatus, FieldKind, Field, CustomField, FormTheme, FilloAppearance, FilloStrings, FilloError, CodeForm, FormSettings, Condition, TextField, PhoneField, NumberField, ChoiceField, SelectOption, CheckboxField, RatingField, LinearScaleField, RankingField, SignatureField, DateField, FileUploadField as FileUploadField$1, HiddenField } from '@usefillo/core';
|
|
5
|
+
export { CodeForm, Field, FieldValue, FileValue, FilloAppearance, FilloClient, FilloError, FilloJsxError, FilloSlot, FilloStrings, FormSchema, FormStatus, FormTheme, ProvisionWorkspaceResult, PublishedForm, ResponseData, SlotState, createClient, defineForm, provisionWorkspace, when } from '@usefillo/core';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Everything a custom renderer needs. Returned by useFillo() and provided
|
|
@@ -27,6 +28,8 @@ interface FilloApi {
|
|
|
27
28
|
status: FormStatus;
|
|
28
29
|
/** True while any file upload is in flight — submit is blocked. */
|
|
29
30
|
uploading: boolean;
|
|
31
|
+
/** Human-readable message for the last failed submit; cleared on edit/retry. */
|
|
32
|
+
submitError?: string;
|
|
30
33
|
/** Used by upload fields to gate submission. */
|
|
31
34
|
setUploading: (fieldId: string, busy: boolean) => void;
|
|
32
35
|
}
|
|
@@ -47,17 +50,36 @@ interface FieldComponentProps<F extends Field = Field> {
|
|
|
47
50
|
api: FilloApi;
|
|
48
51
|
ids?: FilloFieldIds;
|
|
49
52
|
}
|
|
50
|
-
/**
|
|
51
|
-
|
|
53
|
+
/**
|
|
54
|
+
* The Field variant carrying a given kind. Some variants share a union `kind`
|
|
55
|
+
* (ChoiceField is "select" | "multi_select" | "dropdown"), so `Extract` would
|
|
56
|
+
* collapse to `never` — distribute over the union and keep the matching member.
|
|
57
|
+
*/
|
|
58
|
+
type FieldOfKind<K extends FieldKind> = Field extends infer V ? V extends Field ? K extends V["kind"] ? V : never : never : never;
|
|
59
|
+
/**
|
|
60
|
+
* Per-kind component overrides — swap any built-in field for your own. Each
|
|
61
|
+
* kind's `field` is narrowed to its variant, so an override reads it cast-free.
|
|
62
|
+
*/
|
|
63
|
+
type FieldComponents = {
|
|
64
|
+
[K in FieldKind]?: ComponentType<FieldComponentProps<FieldOfKind<K>>>;
|
|
65
|
+
};
|
|
52
66
|
/**
|
|
53
67
|
* Renderers for your own field kinds, keyed by a custom field's `component`.
|
|
54
68
|
* A block `{ kind: "custom", component: "color", config: {...} }` renders
|
|
55
69
|
* `customComponents.color`. The component reads `field.config` for options.
|
|
56
70
|
*/
|
|
57
|
-
type CustomComponents = Record<string, ComponentType<FieldComponentProps
|
|
71
|
+
type CustomComponents = Record<string, ComponentType<FieldComponentProps<CustomField>>>;
|
|
58
72
|
|
|
59
73
|
interface FilloFormBaseProps {
|
|
60
74
|
theme?: FormTheme;
|
|
75
|
+
/**
|
|
76
|
+
* The styling contract: theme tokens plus per-slot class strings (Tailwind
|
|
77
|
+
* or your own), appended after the built-in fillo-* classes so they win by
|
|
78
|
+
* cascade order. `appearance.theme` outranks every other theme source.
|
|
79
|
+
*/
|
|
80
|
+
appearance?: FilloAppearance;
|
|
81
|
+
/** Override any visitor-facing renderer string (for localized sites). */
|
|
82
|
+
strings?: Partial<FilloStrings>;
|
|
61
83
|
/** Swap any built-in field kind for your own component. */
|
|
62
84
|
components?: FieldComponents;
|
|
63
85
|
/** Renderers for your own `custom` field kinds, keyed by `component`. */
|
|
@@ -107,6 +129,85 @@ type PreviewFormProps = FilloFormBaseProps & {
|
|
|
107
129
|
type FilloFormProps = HostedFormProps | CodeBackedFormProps | PreviewFormProps;
|
|
108
130
|
declare function FilloForm(props: FilloFormProps): react.JSX.Element;
|
|
109
131
|
|
|
132
|
+
/**
|
|
133
|
+
* The authoring namespace: `<Fillo.Form id="contact"><Fillo.Email id="email"
|
|
134
|
+
* label="Work email"/></Fillo.Form>`. Field elements are inert descriptors
|
|
135
|
+
* compiled (never rendered) into the exact CodeForm defineForm() emits, then
|
|
136
|
+
* fed to the existing framed <FilloForm> — same sync, same draft-by-default,
|
|
137
|
+
* same badge, same responses. Define forms in a client module ("use client");
|
|
138
|
+
* pass the compiled VALUE across server/client boundaries, never the JSX.
|
|
139
|
+
*/
|
|
140
|
+
type WithVisible<T> = Omit<T, "kind" | "visibleIf"> & {
|
|
141
|
+
visibleIf?: Condition | Condition[];
|
|
142
|
+
};
|
|
143
|
+
type ChoiceProps = Omit<WithVisible<ChoiceField>, "options"> & {
|
|
144
|
+
options?: SelectOption[];
|
|
145
|
+
children?: ReactNode;
|
|
146
|
+
};
|
|
147
|
+
type ContentProps = {
|
|
148
|
+
id: string;
|
|
149
|
+
children?: string;
|
|
150
|
+
text?: string;
|
|
151
|
+
};
|
|
152
|
+
/** Inert: rendering one throws; they exist to be read by the compiler. */
|
|
153
|
+
type Inert<P> = (props: P) => never;
|
|
154
|
+
interface FilloJsxFormProps extends Omit<FilloFormProps, "form" | "formId" | "client"> {
|
|
155
|
+
/** Workspace handle — the form's identity across syncs. */
|
|
156
|
+
id: string;
|
|
157
|
+
title?: string;
|
|
158
|
+
description?: string;
|
|
159
|
+
settings?: FormSettings;
|
|
160
|
+
theme?: FormTheme;
|
|
161
|
+
client?: FilloClient;
|
|
162
|
+
children?: ReactNode;
|
|
163
|
+
}
|
|
164
|
+
declare function JsxForm(props: FilloJsxFormProps): react.JSX.Element;
|
|
165
|
+
declare function defineFormFromJsx(element: ReactElement<FilloJsxFormProps>): CodeForm;
|
|
166
|
+
declare const Fillo: {
|
|
167
|
+
readonly Form: typeof JsxForm;
|
|
168
|
+
/** Compile a <Fillo.Form> element to a CodeForm at module scope — the same
|
|
169
|
+
* value FilloProvider (headless) and the CLI consume. */
|
|
170
|
+
readonly defineForm: typeof defineFormFromJsx;
|
|
171
|
+
readonly Text: Inert<WithVisible<TextField>>;
|
|
172
|
+
readonly LongText: Inert<WithVisible<TextField>>;
|
|
173
|
+
readonly Email: Inert<WithVisible<TextField>>;
|
|
174
|
+
readonly Url: Inert<WithVisible<TextField>>;
|
|
175
|
+
readonly Phone: Inert<WithVisible<PhoneField>>;
|
|
176
|
+
readonly Number: Inert<WithVisible<NumberField>>;
|
|
177
|
+
readonly Select: Inert<ChoiceProps>;
|
|
178
|
+
readonly MultiSelect: Inert<ChoiceProps>;
|
|
179
|
+
readonly Dropdown: Inert<ChoiceProps>;
|
|
180
|
+
readonly Checkbox: Inert<WithVisible<CheckboxField>>;
|
|
181
|
+
readonly Rating: Inert<WithVisible<RatingField>>;
|
|
182
|
+
readonly Scale: Inert<WithVisible<LinearScaleField>>;
|
|
183
|
+
readonly Ranking: Inert<Omit<WithVisible<RankingField>, "options"> & {
|
|
184
|
+
options?: SelectOption[];
|
|
185
|
+
children?: ReactNode;
|
|
186
|
+
}>;
|
|
187
|
+
readonly Matrix: Inert<WithVisible<_usefillo_core.MatrixField>>;
|
|
188
|
+
readonly Signature: Inert<WithVisible<SignatureField>>;
|
|
189
|
+
readonly Date: Inert<WithVisible<DateField>>;
|
|
190
|
+
readonly FileUpload: Inert<WithVisible<FileUploadField$1>>;
|
|
191
|
+
readonly Hidden: Inert<WithVisible<HiddenField>>;
|
|
192
|
+
readonly Custom: Inert<WithVisible<CustomField>>;
|
|
193
|
+
readonly Heading: Inert<ContentProps>;
|
|
194
|
+
readonly Paragraph: Inert<ContentProps>;
|
|
195
|
+
readonly Divider: Inert<{
|
|
196
|
+
id: string;
|
|
197
|
+
}>;
|
|
198
|
+
readonly Page: Inert<{
|
|
199
|
+
id: string;
|
|
200
|
+
title?: string;
|
|
201
|
+
children?: ReactNode;
|
|
202
|
+
}>;
|
|
203
|
+
readonly Option: Inert<Omit<SelectOption, "id"> & {
|
|
204
|
+
id: string;
|
|
205
|
+
}>;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/** The raw appearance object — for renderers that resolve slots inside loops. */
|
|
209
|
+
declare function useFilloAppearance(): FilloAppearance | undefined;
|
|
210
|
+
|
|
110
211
|
interface ControllerOptions {
|
|
111
212
|
form: FormSchema;
|
|
112
213
|
formId?: string;
|
|
@@ -118,8 +219,14 @@ interface ControllerOptions {
|
|
|
118
219
|
getHoneypot?: () => string;
|
|
119
220
|
/** @internal Preview-only page navigation escape hatch. Submission still validates. */
|
|
120
221
|
skipValidation?: boolean;
|
|
121
|
-
/**
|
|
222
|
+
/**
|
|
223
|
+
* Embedding surface, recorded per response for measurement. Defaults to
|
|
224
|
+
* "headless" (your own markup), matching @usefillo/core — the framed
|
|
225
|
+
* renderers pass "default" explicitly.
|
|
226
|
+
*/
|
|
122
227
|
surface?: "default" | "headless";
|
|
228
|
+
/** Resolve the submission target at submit time when formId is still unset. */
|
|
229
|
+
resolveFormId?: () => Promise<string>;
|
|
123
230
|
}
|
|
124
231
|
/**
|
|
125
232
|
* React binding for the framework-agnostic engine in @usefillo/core
|
|
@@ -134,6 +241,10 @@ declare function useFilloController(options: ControllerOptions): FilloApi;
|
|
|
134
241
|
interface FilloProviderProps extends Omit<ControllerOptions, "form"> {
|
|
135
242
|
/** A schema, or a code-defined form from defineForm() — which also syncs. */
|
|
136
243
|
form: FormSchema | CodeForm;
|
|
244
|
+
/** Slot classes for FormField-rendered fields in your composed layout. */
|
|
245
|
+
appearance?: FilloAppearance;
|
|
246
|
+
/** Override any visitor-facing renderer string (for localized sites). */
|
|
247
|
+
strings?: Partial<FilloStrings>;
|
|
137
248
|
children: ReactNode;
|
|
138
249
|
}
|
|
139
250
|
/**
|
|
@@ -155,7 +266,7 @@ interface FilloProviderProps extends Omit<ControllerOptions, "form"> {
|
|
|
155
266
|
* defineForm() form and a keyed client, the structure also syncs into your
|
|
156
267
|
* workspace, exactly like <FilloForm>.
|
|
157
268
|
*/
|
|
158
|
-
declare function FilloProvider({ children, form, formId, client, ...options }: FilloProviderProps): react.JSX.Element;
|
|
269
|
+
declare function FilloProvider({ children, form, formId, client, appearance, strings, ...options }: FilloProviderProps): react.JSX.Element;
|
|
159
270
|
|
|
160
271
|
/**
|
|
161
272
|
* The full form engine — data, errors, pages, submit, status. Use inside a
|
|
@@ -206,4 +317,4 @@ declare function FormField({ id, components, customComponents, }: {
|
|
|
206
317
|
*/
|
|
207
318
|
declare function FileUploadField({ field, value, error, setValue, api, ids: providedIds }: FieldComponentProps): react.JSX.Element;
|
|
208
319
|
|
|
209
|
-
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 };
|
|
320
|
+
export { BlockRenderer, type ControllerOptions, type CustomComponents, type FieldComponentProps, type FieldComponents, type FieldHandle, Fillo, type FilloApi, type FilloFieldIds, FileUploadField as FilloFileUpload, FilloForm, type FilloFormProps, type FilloJsxFormProps, FilloProvider, type FilloProviderProps, FormField, useField, useFillo, useFilloAppearance, useFilloController };
|