@10x-media/form-builder 0.1.0-beta.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/CHANGELOG.md +23 -0
- package/LICENSE +21 -0
- package/README.md +1434 -0
- package/dist/constants-B-BUfetP.d.ts +288 -0
- package/dist/exports/client.d.ts +21 -0
- package/dist/exports/client.js +320 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/i18n.d.ts +138 -0
- package/dist/exports/i18n.js +3 -0
- package/dist/exports/react.d.ts +550 -0
- package/dist/exports/react.js +1564 -0
- package/dist/exports/react.js.map +1 -0
- package/dist/exports/rsc.d.ts +16 -0
- package/dist/exports/rsc.js +55 -0
- package/dist/exports/rsc.js.map +1 -0
- package/dist/exports/types.d.ts +5 -0
- package/dist/exports/types.js +1 -0
- package/dist/fieldTypes-B8jkNRob.d.ts +188 -0
- package/dist/fieldTypes-CzhhJXjg.js +88 -0
- package/dist/fieldTypes-CzhhJXjg.js.map +1 -0
- package/dist/index-DfFYGbVF.d.ts +481 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1921 -0
- package/dist/index.js.map +1 -0
- package/dist/keys-N5xGiUsh.js +132 -0
- package/dist/keys-N5xGiUsh.js.map +1 -0
- package/dist/registry-CoCyhtvB.js +282 -0
- package/dist/registry-CoCyhtvB.js.map +1 -0
- package/dist/resolver-OeQyVH2N.js +665 -0
- package/dist/resolver-OeQyVH2N.js.map +1 -0
- package/dist/translations-edMqq_2e.js +152 -0
- package/dist/translations-edMqq_2e.js.map +1 -0
- package/dist/types-DsJ_6kGJ.d.ts +23 -0
- package/package.json +125 -0
- package/styles/form-builder.css +108 -0
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
import { n as AnyFormFieldDefinition } from "../fieldTypes-B8jkNRob.js";
|
|
2
|
+
import { C as evaluateCalc, D as AggregationBucket, E as CalcExpression, F as SubmissionValue, M as FormFieldInstance, S as evaluateCondition, T as computeCalcFields, _ as PrefillOptions, c as PresentationDescriptor, g as FormEventSink, i as buildRecallResolver, k as FieldAggregation, n as DEFAULT_HONEYPOT_FIELD, o as interpolate, r as RecallResolver, t as CAPTCHA_TOKEN_KEY, u as AnyValidationRuleDefinition, v as valuesFromSearchParams } from "../constants-B-BUfetP.js";
|
|
3
|
+
import { r as FormFlow } from "../types-DsJ_6kGJ.js";
|
|
4
|
+
import { ComponentType, ReactNode, Ref, RefObject } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/flow/engine.d.ts
|
|
7
|
+
/** The entry step id (the first step), or `undefined` for an empty flow. */
|
|
8
|
+
declare const firstStepId: (flow: FormFlow) => string | undefined;
|
|
9
|
+
/** The field machine names a step renders (empty for an unknown step). */
|
|
10
|
+
declare const stepFieldNames: (flow: FormFlow, id: string) => string[];
|
|
11
|
+
/**
|
|
12
|
+
* Resolve the next step id from the current step + answers: the first transition whose `when` matches
|
|
13
|
+
* (via `evaluateCondition`), else the default `next`, else `undefined` (terminal). Pure + isomorphic.
|
|
14
|
+
*/
|
|
15
|
+
declare const resolveNextStepId: (flow: FormFlow, currentId: string, answers: Record<string, unknown>) => string | undefined;
|
|
16
|
+
/** Whether the current step is terminal (no matching transition + no default next). */
|
|
17
|
+
declare const isTerminalStepId: (flow: FormFlow, currentId: string, answers: Record<string, unknown>) => boolean;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/react/contract.d.ts
|
|
20
|
+
/** A localized translator the renderer uses for built-in copy. `(key) => string`; unknown keys return the key. */
|
|
21
|
+
type RendererTranslate = (key: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* The props every field renderer receives. The renderer turns one field instance plus its current value
|
|
24
|
+
* into an accessible control. Supplied by `<Form>` or directly in tests. Generic over the
|
|
25
|
+
* value type so custom renderers can narrow it.
|
|
26
|
+
*/
|
|
27
|
+
type FieldRendererProps<TValue = unknown> = {
|
|
28
|
+
/** The stored field instance (name, label, blockType, required, placeholder, description, options, ...). */field: FormFieldInstance; /** The control's stable id, for label/aria wiring. */
|
|
29
|
+
id: string; /** The field machine name (form value key). */
|
|
30
|
+
name: string;
|
|
31
|
+
value: TValue | undefined;
|
|
32
|
+
onChange: (value: TValue) => void;
|
|
33
|
+
onBlur: () => void; /** Blocking error messages for this field (already filtered to error severity). */
|
|
34
|
+
errors: string[]; /** Advisory messages (warning severity). */
|
|
35
|
+
warnings?: string[];
|
|
36
|
+
required: boolean;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
locale: string;
|
|
39
|
+
t: RendererTranslate;
|
|
40
|
+
};
|
|
41
|
+
/** A field renderer: maps `FieldRendererProps` to React output. */
|
|
42
|
+
type FieldRenderer<TValue = unknown> = (props: FieldRendererProps<TValue>) => ReactNode;
|
|
43
|
+
/** Identity helper that pins a renderer to the `FieldRenderer` type so authors get prop inference. */
|
|
44
|
+
declare const defineFieldRenderer: <TValue = unknown>(renderer: FieldRenderer<TValue>) => FieldRenderer<TValue>;
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/react/presentation/types.d.ts
|
|
47
|
+
type PresentationWrapperProps = {
|
|
48
|
+
presentation: FormPresentation;
|
|
49
|
+
open: boolean;
|
|
50
|
+
onClose: () => void; /** Accessible name for an overlay surface (e.g. the form title). */
|
|
51
|
+
title?: string; /** Label for the overlay close control. */
|
|
52
|
+
closeLabel?: string;
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
};
|
|
55
|
+
/** A descriptor plus an optional React wrapper. page/inline omit the wrapper; modal/drawer provide one. */
|
|
56
|
+
type FormPresentation = PresentationDescriptor & {
|
|
57
|
+
Wrapper?: ComponentType<PresentationWrapperProps>;
|
|
58
|
+
};
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/react/presentation/registry.d.ts
|
|
61
|
+
type PresentationRegistry = Map<string, FormPresentation>;
|
|
62
|
+
/** `false` removes, `true` keeps the default, a presentation adds or replaces one. */
|
|
63
|
+
type PresentationOption = boolean | FormPresentation;
|
|
64
|
+
type PresentationsConfig = Record<string, PresentationOption>;
|
|
65
|
+
declare const resolvePresentations: (defaults?: Record<string, FormPresentation>, config?: PresentationsConfig) => PresentationRegistry;
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/react/registry.d.ts
|
|
68
|
+
type RendererRegistry = Map<string, FieldRenderer>;
|
|
69
|
+
/** Per-type renderer override: `false` removes, `true` keeps the default, a renderer adds or replaces one. */
|
|
70
|
+
type RendererOption = boolean | FieldRenderer;
|
|
71
|
+
type RenderersConfig = Record<string, RendererOption>;
|
|
72
|
+
/**
|
|
73
|
+
* Resolve the active renderer registry from the defaults and a consumer override map. `false` removes a
|
|
74
|
+
* type, `true` keeps the default (no-op when none exists), a renderer adds a new type or replaces one.
|
|
75
|
+
* Mirrors the field-type and validation-rule registry convention.
|
|
76
|
+
*/
|
|
77
|
+
declare const resolveRenderers: (defaults: Record<string, FieldRenderer>, config?: RenderersConfig) => RendererRegistry;
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/react/submitForm.d.ts
|
|
80
|
+
type SubmitFormInput = {
|
|
81
|
+
formId: number | string;
|
|
82
|
+
values: SubmissionValue[]; /** Payload API route prefix; defaults to `/api`. */
|
|
83
|
+
apiRoute?: string; /** Injectable for testing; defaults to global `fetch`. */
|
|
84
|
+
fetchImpl?: typeof fetch;
|
|
85
|
+
};
|
|
86
|
+
type SubmitFormResult = {
|
|
87
|
+
ok: true;
|
|
88
|
+
submissionId?: string;
|
|
89
|
+
} | {
|
|
90
|
+
ok: false;
|
|
91
|
+
fieldErrors?: Record<string, string[]>;
|
|
92
|
+
message?: string;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* The default submission transport: POST `{apiRoute}/form-submissions` with `{ form, values }`. On 201
|
|
96
|
+
* returns the created submission id; on a 400 Payload `ValidationError` maps `data.errors[].path` to
|
|
97
|
+
* per-field messages; otherwise returns a generic message. Pure: inject `fetchImpl` in tests.
|
|
98
|
+
*/
|
|
99
|
+
declare const submitForm: (input: SubmitFormInput) => Promise<SubmitFormResult>;
|
|
100
|
+
/** A consumer override for the transport: given the form id + values, resolve to a submit result. */
|
|
101
|
+
type SubmitHandler = (input: {
|
|
102
|
+
formId: number | string;
|
|
103
|
+
values: SubmissionValue[];
|
|
104
|
+
}) => Promise<SubmitFormResult>;
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/react/Form.d.ts
|
|
107
|
+
type FormDocument = {
|
|
108
|
+
id: number | string;
|
|
109
|
+
fields: FormFieldInstance[];
|
|
110
|
+
flow?: FormFlow; /** Stored presentation name; overridden by the `presentation` prop. */
|
|
111
|
+
defaultPresentation?: string;
|
|
112
|
+
};
|
|
113
|
+
type FormProps = {
|
|
114
|
+
form: FormDocument;
|
|
115
|
+
fieldTypes?: AnyFormFieldDefinition[];
|
|
116
|
+
rules?: AnyValidationRuleDefinition[];
|
|
117
|
+
renderers?: RenderersConfig;
|
|
118
|
+
apiRoute?: string;
|
|
119
|
+
onSubmit?: SubmitHandler;
|
|
120
|
+
onSuccess?: (submissionId?: string) => void;
|
|
121
|
+
onError?: (message: string) => void;
|
|
122
|
+
events?: FormEventSink;
|
|
123
|
+
t?: RendererTranslate;
|
|
124
|
+
locale?: string;
|
|
125
|
+
layout?: boolean;
|
|
126
|
+
submitLabel?: string;
|
|
127
|
+
nextLabel?: string;
|
|
128
|
+
backLabel?: string; /** Label for the overlay close control (modal/drawer). */
|
|
129
|
+
closeLabel?: string;
|
|
130
|
+
successMessage?: string; /** Active presentation: a name into the registry or an inline presentation. Overrides the form's stored default. */
|
|
131
|
+
presentation?: string | FormPresentation; /** Per-render presentation overrides merged onto the defaults (add, replace, or `false` to remove). */
|
|
132
|
+
presentations?: PresentationsConfig; /** Invoked when an overlay presentation dismisses (close button, Escape, outside click, or `dismissOnSuccess`). */
|
|
133
|
+
onClose?: () => void; /** Accessible name for an overlay surface. */
|
|
134
|
+
title?: string; /** Seed initial field values (e.g. from `valuesFromSearchParams`). Still validated on submit. */
|
|
135
|
+
initialValues?: Record<string, unknown>; /** Honeypot decoy (on by default). `false` removes it; `{ name }` matches a customized server `spam.honeypot.fieldName`. */
|
|
136
|
+
honeypot?: false | {
|
|
137
|
+
name?: string;
|
|
138
|
+
}; /** A token from your captcha widget; verified server-side when a captcha provider is configured. */
|
|
139
|
+
captchaToken?: string; /** Custom layout: render fields with `useField`/`useFormState` instead of the auto-rendered field loop. */
|
|
140
|
+
children?: ReactNode;
|
|
141
|
+
};
|
|
142
|
+
/** The headless form controller: state, progressive client validation, conditional visibility, submission, events. */
|
|
143
|
+
declare const Form: ({
|
|
144
|
+
form,
|
|
145
|
+
fieldTypes,
|
|
146
|
+
rules,
|
|
147
|
+
renderers,
|
|
148
|
+
apiRoute,
|
|
149
|
+
onSubmit,
|
|
150
|
+
onSuccess,
|
|
151
|
+
onError,
|
|
152
|
+
events,
|
|
153
|
+
t,
|
|
154
|
+
locale,
|
|
155
|
+
layout,
|
|
156
|
+
submitLabel,
|
|
157
|
+
nextLabel,
|
|
158
|
+
backLabel,
|
|
159
|
+
closeLabel,
|
|
160
|
+
successMessage,
|
|
161
|
+
presentation,
|
|
162
|
+
presentations,
|
|
163
|
+
onClose,
|
|
164
|
+
title,
|
|
165
|
+
initialValues,
|
|
166
|
+
honeypot,
|
|
167
|
+
captchaToken,
|
|
168
|
+
children
|
|
169
|
+
}: FormProps) => import("react/jsx-runtime").JSX.Element;
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/react/state.d.ts
|
|
172
|
+
type FieldErrors = Record<string, string[]>;
|
|
173
|
+
type FormState = {
|
|
174
|
+
values: Record<string, unknown>;
|
|
175
|
+
errors: FieldErrors;
|
|
176
|
+
warnings: FieldErrors;
|
|
177
|
+
touched: Record<string, boolean>;
|
|
178
|
+
submitting: boolean;
|
|
179
|
+
submitted: boolean;
|
|
180
|
+
submitAttempted: boolean;
|
|
181
|
+
submitError?: string;
|
|
182
|
+
};
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/react/FormContext.d.ts
|
|
185
|
+
/** Multi-step navigation state. Defaults to a single terminal step when the form has no flow. */
|
|
186
|
+
type FormStepInfo = {
|
|
187
|
+
flow?: FormFlow;
|
|
188
|
+
currentStepId?: string;
|
|
189
|
+
stepIndex: number;
|
|
190
|
+
stepCount: number;
|
|
191
|
+
isFirst: boolean;
|
|
192
|
+
isTerminal: boolean;
|
|
193
|
+
goNext: () => void;
|
|
194
|
+
goBack: () => void;
|
|
195
|
+
};
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/react/FormLayout.d.ts
|
|
198
|
+
type FieldWidth = 'full' | 'half' | 'third' | 'twoThirds';
|
|
199
|
+
type FormLayoutProps = {
|
|
200
|
+
children: ReactNode; /** When false, render a plain container with no grid class (document-order layout). */
|
|
201
|
+
enabled?: boolean;
|
|
202
|
+
};
|
|
203
|
+
/** Establishes the layout container. With the stylesheet imported, children with `data-width` flow into a grid. */
|
|
204
|
+
declare const FormLayout: ({
|
|
205
|
+
children,
|
|
206
|
+
enabled
|
|
207
|
+
}: FormLayoutProps) => import("react/jsx-runtime").JSX.Element;
|
|
208
|
+
/** Props to spread onto a field wrapper to declare its grid width. */
|
|
209
|
+
declare const widthProps: (width: FieldWidth | undefined) => {
|
|
210
|
+
'data-width': FieldWidth;
|
|
211
|
+
};
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/react/FormResults.d.ts
|
|
214
|
+
type FormResultsProps = {
|
|
215
|
+
/** One field aggregation or several (a survey summary), resolved server-side and passed in. */results: FieldAggregation | FieldAggregation[]; /** Localized translator for built-in copy. Defaults to identity (returns the key). */
|
|
216
|
+
t?: RendererTranslate;
|
|
217
|
+
locale?: string; /** Show the raw count beside each option. Default true. */
|
|
218
|
+
showCounts?: boolean;
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Presentational results view for polls and survey summaries: per-option bars with percentages. Headless,
|
|
222
|
+
* data resolved server-side via `aggregateFieldResponses`/`aggregateFormResponses` and passed in (it never
|
|
223
|
+
* fetches). The option label, count, and percentage are real text (the accessible content); the bar fill
|
|
224
|
+
* is `aria-hidden` visual sugar sized by inline width.
|
|
225
|
+
*/
|
|
226
|
+
declare const FormResults: ({
|
|
227
|
+
results,
|
|
228
|
+
t,
|
|
229
|
+
showCounts
|
|
230
|
+
}: FormResultsProps) => ReactNode;
|
|
231
|
+
//#endregion
|
|
232
|
+
//#region src/react/fetchResults.d.ts
|
|
233
|
+
type FetchResultsInput = {
|
|
234
|
+
formId: number | string; /** Restrict to one field. Omit to get every public/enumerable field. */
|
|
235
|
+
field?: string; /** Payload API route prefix; defaults to `/api`. */
|
|
236
|
+
apiRoute?: string; /** Injectable for testing; defaults to global `fetch`. */
|
|
237
|
+
fetchImpl?: typeof fetch;
|
|
238
|
+
};
|
|
239
|
+
type FetchResultsResult = {
|
|
240
|
+
ok: true;
|
|
241
|
+
results: FieldAggregation[];
|
|
242
|
+
} | {
|
|
243
|
+
ok: false;
|
|
244
|
+
message?: string;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Fetch aggregate poll/survey results from the form-builder results endpoint
|
|
248
|
+
* (`GET {apiRoute}/forms/:id/results`). Returns the server-resolved aggregations; the endpoint gates public
|
|
249
|
+
* access by the form's `showResults` opt-in. Pure: inject `fetchImpl` in tests.
|
|
250
|
+
*/
|
|
251
|
+
declare const fetchFormResults: (input: FetchResultsInput) => Promise<FetchResultsResult>;
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region src/react/Honeypot.d.ts
|
|
254
|
+
type HoneypotProps = {
|
|
255
|
+
name: string;
|
|
256
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* A visually hidden honeypot decoy. Real users never see or tab to it; bots that fill every input trip it,
|
|
260
|
+
* and the server rejects the submission. Off-screen + aria-hidden + tabIndex -1 + autoComplete off.
|
|
261
|
+
*/
|
|
262
|
+
declare const Honeypot: ({
|
|
263
|
+
name,
|
|
264
|
+
inputRef
|
|
265
|
+
}: HoneypotProps) => import("react/jsx-runtime").JSX.Element;
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/react/Poll.d.ts
|
|
268
|
+
type PollProps = FormProps & {
|
|
269
|
+
/** The choice field whose results are shown after voting (should match the form's public `resultsField`). */resultsField: string; /** localStorage key for the per-browser voted guard. Default `fb-poll-{form.id}`. */
|
|
270
|
+
storageKey?: string; /** Force the voted state (controlled). Omit to use the localStorage guard. */
|
|
271
|
+
hasVoted?: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Injectable results fetch (testing); defaults to `fetchFormResults`. Pass a stable reference (module
|
|
274
|
+
* scope, `useCallback`, or `useMemo`): an inline function re-runs the load effect and double-fetches.
|
|
275
|
+
*/
|
|
276
|
+
fetchResultsImpl?: typeof fetchFormResults;
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* A poll: renders `<Form>` until the visitor votes, then fetches the aggregate results and shows
|
|
280
|
+
* `<FormResults>`. A per-browser localStorage flag (`storageKey`) skips straight to results on revisit. The
|
|
281
|
+
* guard is UX, not integrity (bypassable): server-enforced one-per-identity dedup composes via `req.user`
|
|
282
|
+
* (authed forms) or a `notAlreadySubmitted` rule, with cookie/IP identity deferred to the spam phase.
|
|
283
|
+
*/
|
|
284
|
+
declare const Poll: ({
|
|
285
|
+
resultsField,
|
|
286
|
+
storageKey,
|
|
287
|
+
hasVoted,
|
|
288
|
+
fetchResultsImpl,
|
|
289
|
+
apiRoute,
|
|
290
|
+
onSuccess,
|
|
291
|
+
...formProps
|
|
292
|
+
}: PollProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
293
|
+
//#endregion
|
|
294
|
+
//#region src/react/presentation/Backdrop.d.ts
|
|
295
|
+
type BackdropProps = {
|
|
296
|
+
onClick?: () => void;
|
|
297
|
+
className?: string;
|
|
298
|
+
};
|
|
299
|
+
/** A full-viewport backdrop behind an overlay surface. Styling comes from the `data-fb-backdrop` hook. */
|
|
300
|
+
declare const Backdrop: ({
|
|
301
|
+
onClick,
|
|
302
|
+
className
|
|
303
|
+
}: BackdropProps) => import("react").DetailedReactHTMLElement<{
|
|
304
|
+
'data-fb-backdrop': string;
|
|
305
|
+
className: string | undefined;
|
|
306
|
+
onClick: (() => void) | undefined;
|
|
307
|
+
'aria-hidden': true;
|
|
308
|
+
}, HTMLElement>;
|
|
309
|
+
//#endregion
|
|
310
|
+
//#region src/react/presentation/DialogSurface.d.ts
|
|
311
|
+
type DialogSurfaceProps = {
|
|
312
|
+
open: boolean;
|
|
313
|
+
onClose: () => void; /** Accessible name; pass either label or labelledBy. */
|
|
314
|
+
label?: string;
|
|
315
|
+
labelledBy?: string; /** CSS data hook, e.g. 'modal' | 'drawer'. */
|
|
316
|
+
surface?: string;
|
|
317
|
+
closeLabel?: string;
|
|
318
|
+
closeOnEscape?: boolean;
|
|
319
|
+
closeOnOutsideClick?: boolean;
|
|
320
|
+
children?: ReactNode;
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* Accessible, dependency-free overlay surface: backdrop + role=dialog/aria-modal, focus-trap,
|
|
324
|
+
* scroll-lock, Escape/outside-click dismiss, initial focus, and focus restore on close. Composes the
|
|
325
|
+
* exported primitives so a consumer can rebuild it from the same parts.
|
|
326
|
+
*/
|
|
327
|
+
declare const DialogSurface: ({
|
|
328
|
+
open,
|
|
329
|
+
onClose,
|
|
330
|
+
label,
|
|
331
|
+
labelledBy,
|
|
332
|
+
surface,
|
|
333
|
+
closeLabel,
|
|
334
|
+
closeOnEscape,
|
|
335
|
+
closeOnOutsideClick,
|
|
336
|
+
children
|
|
337
|
+
}: DialogSurfaceProps) => import("react").ReactElement<{
|
|
338
|
+
'data-fb-overlay': string;
|
|
339
|
+
}, string | import("react").JSXElementConstructor<any>> | null;
|
|
340
|
+
//#endregion
|
|
341
|
+
//#region src/react/presentation/presentations.d.ts
|
|
342
|
+
declare const defaultPresentations: Record<string, FormPresentation>;
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/react/presentation/useDismiss.d.ts
|
|
345
|
+
type UseDismissOptions = {
|
|
346
|
+
active: boolean;
|
|
347
|
+
onDismiss: () => void;
|
|
348
|
+
closeOnEscape?: boolean;
|
|
349
|
+
closeOnOutsideClick?: boolean;
|
|
350
|
+
};
|
|
351
|
+
/** Dismiss-on-Escape and dismiss-on-outside-pointerdown for an overlay surface. */
|
|
352
|
+
declare const useDismiss: ({
|
|
353
|
+
active,
|
|
354
|
+
onDismiss,
|
|
355
|
+
closeOnEscape,
|
|
356
|
+
closeOnOutsideClick
|
|
357
|
+
}: UseDismissOptions, ref: RefObject<HTMLElement | null>) => void;
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/react/presentation/useFocusTrap.d.ts
|
|
360
|
+
/** Trap Tab focus within the container while active. */
|
|
361
|
+
declare const useFocusTrap: (ref: RefObject<HTMLElement | null>, active: boolean) => void;
|
|
362
|
+
//#endregion
|
|
363
|
+
//#region src/react/presentation/useScrollLock.d.ts
|
|
364
|
+
/** Lock body scroll while active; restores the prior value on cleanup. */
|
|
365
|
+
declare const useScrollLock: (active: boolean) => void;
|
|
366
|
+
//#endregion
|
|
367
|
+
//#region src/react/primitives/Checkbox.d.ts
|
|
368
|
+
type CheckboxProps = {
|
|
369
|
+
id: string;
|
|
370
|
+
name: string;
|
|
371
|
+
checked: boolean;
|
|
372
|
+
onChange: (checked: boolean) => void;
|
|
373
|
+
onBlur?: () => void;
|
|
374
|
+
required?: boolean;
|
|
375
|
+
disabled?: boolean;
|
|
376
|
+
invalid?: boolean;
|
|
377
|
+
describedById?: string;
|
|
378
|
+
};
|
|
379
|
+
declare const Checkbox: ({
|
|
380
|
+
id,
|
|
381
|
+
name,
|
|
382
|
+
checked,
|
|
383
|
+
onChange,
|
|
384
|
+
onBlur,
|
|
385
|
+
required,
|
|
386
|
+
disabled,
|
|
387
|
+
invalid,
|
|
388
|
+
describedById
|
|
389
|
+
}: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
|
|
390
|
+
//#endregion
|
|
391
|
+
//#region src/react/primitives/FieldShell.d.ts
|
|
392
|
+
type FieldShellProps = {
|
|
393
|
+
/** The control id this shell labels and describes. */id: string;
|
|
394
|
+
label?: string;
|
|
395
|
+
description?: string;
|
|
396
|
+
required?: boolean;
|
|
397
|
+
errors?: string[];
|
|
398
|
+
warnings?: string[]; /** id used for aria-describedby on the control; the shell renders description + messages under it. */
|
|
399
|
+
describedById: string;
|
|
400
|
+
children: ReactNode;
|
|
401
|
+
};
|
|
402
|
+
/**
|
|
403
|
+
* Accessible wrapper for a single field: a `<label>` bound to the control, the control slot, an optional
|
|
404
|
+
* description, and error/warning messages. The control inside must set `aria-describedby={describedById}`
|
|
405
|
+
* and `aria-invalid` when errors exist; this shell renders the matching `id={describedById}` region.
|
|
406
|
+
*/
|
|
407
|
+
declare const FieldShell: ({
|
|
408
|
+
id,
|
|
409
|
+
label,
|
|
410
|
+
description,
|
|
411
|
+
required,
|
|
412
|
+
errors,
|
|
413
|
+
warnings,
|
|
414
|
+
describedById,
|
|
415
|
+
children
|
|
416
|
+
}: FieldShellProps) => import("react/jsx-runtime").JSX.Element;
|
|
417
|
+
//#endregion
|
|
418
|
+
//#region src/react/primitives/Input.d.ts
|
|
419
|
+
type InputProps = {
|
|
420
|
+
id: string;
|
|
421
|
+
name: string;
|
|
422
|
+
type?: 'text' | 'email' | 'number';
|
|
423
|
+
value: string;
|
|
424
|
+
onChange: (value: string) => void;
|
|
425
|
+
onBlur?: () => void;
|
|
426
|
+
placeholder?: string;
|
|
427
|
+
required?: boolean;
|
|
428
|
+
disabled?: boolean;
|
|
429
|
+
invalid?: boolean;
|
|
430
|
+
describedById?: string;
|
|
431
|
+
};
|
|
432
|
+
declare const Input: ({
|
|
433
|
+
id,
|
|
434
|
+
name,
|
|
435
|
+
type,
|
|
436
|
+
value,
|
|
437
|
+
onChange,
|
|
438
|
+
onBlur,
|
|
439
|
+
placeholder,
|
|
440
|
+
required,
|
|
441
|
+
disabled,
|
|
442
|
+
invalid,
|
|
443
|
+
describedById
|
|
444
|
+
}: InputProps) => import("react/jsx-runtime").JSX.Element;
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region src/react/primitives/Select.d.ts
|
|
447
|
+
type SelectOption = {
|
|
448
|
+
label: string;
|
|
449
|
+
value: string;
|
|
450
|
+
};
|
|
451
|
+
type SelectProps = {
|
|
452
|
+
id: string;
|
|
453
|
+
name: string;
|
|
454
|
+
value: string;
|
|
455
|
+
options: SelectOption[];
|
|
456
|
+
onChange: (value: string) => void;
|
|
457
|
+
onBlur?: () => void;
|
|
458
|
+
required?: boolean;
|
|
459
|
+
disabled?: boolean;
|
|
460
|
+
invalid?: boolean;
|
|
461
|
+
describedById?: string;
|
|
462
|
+
placeholder?: string;
|
|
463
|
+
};
|
|
464
|
+
declare const Select: ({
|
|
465
|
+
id,
|
|
466
|
+
name,
|
|
467
|
+
value,
|
|
468
|
+
options,
|
|
469
|
+
onChange,
|
|
470
|
+
onBlur,
|
|
471
|
+
required,
|
|
472
|
+
disabled,
|
|
473
|
+
invalid,
|
|
474
|
+
describedById,
|
|
475
|
+
placeholder
|
|
476
|
+
}: SelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
477
|
+
//#endregion
|
|
478
|
+
//#region src/react/primitives/Textarea.d.ts
|
|
479
|
+
type TextareaProps = {
|
|
480
|
+
id: string;
|
|
481
|
+
name: string;
|
|
482
|
+
value: string;
|
|
483
|
+
onChange: (value: string) => void;
|
|
484
|
+
onBlur?: () => void;
|
|
485
|
+
placeholder?: string;
|
|
486
|
+
required?: boolean;
|
|
487
|
+
disabled?: boolean;
|
|
488
|
+
invalid?: boolean;
|
|
489
|
+
describedById?: string;
|
|
490
|
+
};
|
|
491
|
+
declare const Textarea: ({
|
|
492
|
+
id,
|
|
493
|
+
name,
|
|
494
|
+
value,
|
|
495
|
+
onChange,
|
|
496
|
+
onBlur,
|
|
497
|
+
placeholder,
|
|
498
|
+
required,
|
|
499
|
+
disabled,
|
|
500
|
+
invalid,
|
|
501
|
+
describedById
|
|
502
|
+
}: TextareaProps) => import("react/jsx-runtime").JSX.Element;
|
|
503
|
+
//#endregion
|
|
504
|
+
//#region src/react/renderers/index.d.ts
|
|
505
|
+
/** The built-in field renderers, keyed by field-type slug. Override via the renderer registry. */
|
|
506
|
+
declare const defaultRenderers: Record<string, FieldRenderer>;
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region src/react/uploadFile.d.ts
|
|
509
|
+
type UploadFileInput = {
|
|
510
|
+
file: File; /** Upload collection slug. Defaults to `form-uploads`. */
|
|
511
|
+
collection?: string;
|
|
512
|
+
apiRoute?: string;
|
|
513
|
+
fetchImpl?: typeof fetch;
|
|
514
|
+
};
|
|
515
|
+
type UploadFileResult = {
|
|
516
|
+
ok: true;
|
|
517
|
+
id: string | number;
|
|
518
|
+
} | {
|
|
519
|
+
ok: false;
|
|
520
|
+
message?: string;
|
|
521
|
+
};
|
|
522
|
+
/**
|
|
523
|
+
* Upload one file to a Payload upload collection (`POST {apiRoute}/{collection}`, multipart) and return its
|
|
524
|
+
* id, which the file field stores as its value. The server re-derives the file metadata from the stored doc
|
|
525
|
+
* at submit, so the client is never trusted for it. Pure: inject `fetchImpl` in tests.
|
|
526
|
+
*/
|
|
527
|
+
declare const uploadFile: (input: UploadFileInput) => Promise<UploadFileResult>;
|
|
528
|
+
//#endregion
|
|
529
|
+
//#region src/react/useField.d.ts
|
|
530
|
+
type UseFieldResult<TValue = unknown> = {
|
|
531
|
+
value: TValue | undefined;
|
|
532
|
+
errors: string[];
|
|
533
|
+
warnings: string[];
|
|
534
|
+
touched: boolean;
|
|
535
|
+
setValue: (value: TValue) => void; /** Mark touched and validate now (call on blur). */
|
|
536
|
+
onBlur: () => void;
|
|
537
|
+
};
|
|
538
|
+
/** Bind one field by name to the form controller: its value, issues, and change/blur handlers. */
|
|
539
|
+
declare const useField: <TValue = unknown>(name: string) => UseFieldResult<TValue>;
|
|
540
|
+
//#endregion
|
|
541
|
+
//#region src/react/useFormState.d.ts
|
|
542
|
+
/** The whole form state (values, errors, warnings, touched, submitting, submitted, submitError). */
|
|
543
|
+
declare const useFormState: () => FormState;
|
|
544
|
+
//#endregion
|
|
545
|
+
//#region src/react/useFormStep.d.ts
|
|
546
|
+
/** Multi-step navigation state for the current form (single-step default when the form has no flow). */
|
|
547
|
+
declare const useFormStep: () => FormStepInfo;
|
|
548
|
+
//#endregion
|
|
549
|
+
export { type AggregationBucket, Backdrop, type BackdropProps, CAPTCHA_TOKEN_KEY, type CalcExpression, Checkbox, type CheckboxProps, DEFAULT_HONEYPOT_FIELD, DialogSurface, type DialogSurfaceProps, type FetchResultsInput, type FetchResultsResult, type FieldAggregation, type FieldRenderer, type FieldRendererProps, FieldShell, type FieldShellProps, type FieldWidth, Form, type FormDocument, FormLayout, type FormLayoutProps, type FormPresentation, type FormProps, FormResults, type FormResultsProps, type FormState, type FormStepInfo, Honeypot, type HoneypotProps, Input, type InputProps, Poll, type PollProps, type PrefillOptions, type PresentationOption, type PresentationRegistry, type PresentationWrapperProps, type PresentationsConfig, type RecallResolver, type RendererOption, type RendererRegistry, type RendererTranslate, type RenderersConfig, Select, type SelectOption, type SelectProps, type SubmitFormResult, type SubmitHandler, Textarea, type TextareaProps, type UploadFileInput, type UploadFileResult, type UseDismissOptions, type UseFieldResult, buildRecallResolver, computeCalcFields, defaultPresentations, defaultRenderers, defineFieldRenderer, evaluateCalc, evaluateCondition, fetchFormResults, firstStepId, interpolate, isTerminalStepId, resolveNextStepId, resolvePresentations, resolveRenderers, stepFieldNames, submitForm, uploadFile, useDismiss, useField, useFocusTrap, useFormState, useFormStep, useScrollLock, valuesFromSearchParams, widthProps };
|
|
550
|
+
//# sourceMappingURL=react.d.ts.map
|