@formancy/react 0.4.0 → 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.mts +52 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +304 -127
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
import { ComponentType, ReactElement, ReactNode } from "react";
|
|
2
2
|
import { ControlProps, FieldSnapshot, FormEngine, Path } from "@formancy/core";
|
|
3
|
-
import {
|
|
3
|
+
import { FormText, FormText as FormText$1, FormWordId, FormWordValues, FormWords, FormWordsByLocale, FormWordsByLocale as FormWordsByLocale$1 } from "@formancy/core/words";
|
|
4
|
+
import { FieldType, RemoteOption, RemoteOptionsAnswer, RemoteOptionsAnswer as RemoteOptionsAnswer$1, RemoteOptionsPage, RichCommand } from "@formancy/spec";
|
|
4
5
|
//#region src/context.d.ts
|
|
5
|
-
export declare function FormancyProvider({ engine, children }: {
|
|
6
|
+
export declare function FormancyProvider({ engine, words, children }: {
|
|
6
7
|
engine: FormEngine;
|
|
8
|
+
/**
|
|
9
|
+
* Languages a host adds, and words it changes, by locale: `{ it: { 'form.next':
|
|
10
|
+
* 'Avanti' } }`, or `{ en: { 'form.submit': 'Send' } }`. Read in the language the
|
|
11
|
+
* questions are, a word at a time, and English for the rest. A constant, as any context
|
|
12
|
+
* value should be: a new object on every render is a new language for every control below.
|
|
13
|
+
*/
|
|
14
|
+
words?: FormWordsByLocale$1;
|
|
7
15
|
children?: ReactNode;
|
|
8
16
|
}): import("react").JSX.Element;
|
|
9
17
|
export declare function useFormEngine(): FormEngine;
|
|
18
|
+
/**
|
|
19
|
+
* The form's words, in the language the reader chose for it.
|
|
20
|
+
*
|
|
21
|
+
* English outside a `FormancyProvider`, which has no engine to take a language from — a
|
|
22
|
+
* resume notice a host draws beside the form rather than inside its provider. Never the
|
|
23
|
+
* browser's language: the form's is the one the reader chose, and the browser's is the
|
|
24
|
+
* one their machine came with.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useFormText(): FormText$1;
|
|
10
27
|
//#endregion
|
|
11
28
|
//#region src/use-field.d.ts
|
|
12
29
|
interface FieldBinding extends FieldSnapshot {
|
|
@@ -41,6 +58,10 @@ interface RepeaterBinding {
|
|
|
41
58
|
rowCount: number;
|
|
42
59
|
/** Stable per-row keys, in row order. Never key a row by its index. */
|
|
43
60
|
rowIds: readonly string[];
|
|
61
|
+
/** Whether the engine would add a row: under the repeater's `maxItems`, or unbounded. */
|
|
62
|
+
canAdd: boolean;
|
|
63
|
+
/** Whether the engine would remove a row: above the repeater's `minItems`. */
|
|
64
|
+
canRemove: boolean;
|
|
44
65
|
addRow(): void;
|
|
45
66
|
removeRow(index: number): void;
|
|
46
67
|
/** Move a row. The keyboard route to reordering; a drag is a second route to this. */
|
|
@@ -229,7 +250,13 @@ interface OptionsRequest {
|
|
|
229
250
|
* shows an opaque identifier. So the source answers in the right language instead.
|
|
230
251
|
*/
|
|
231
252
|
locale: string;
|
|
232
|
-
/**
|
|
253
|
+
/**
|
|
254
|
+
* How many rows the control can show. A hint: the control caps what arrives anyway.
|
|
255
|
+
*
|
|
256
|
+
* A source that pages reads `limit + 1` rows to know whether there are more, answers a
|
|
257
|
+
* page of `limit`, and never counts the rest: a count reads every matching row on every
|
|
258
|
+
* keystroke, which is the scan paging exists to avoid.
|
|
259
|
+
*/
|
|
233
260
|
limit: number;
|
|
234
261
|
/** Aborted when the answer stops being wanted — a newer keystroke, or an unmount. */
|
|
235
262
|
signal: AbortSignal;
|
|
@@ -244,10 +271,26 @@ interface OptionsRequest {
|
|
|
244
271
|
* surface on a self-hosted instance.
|
|
245
272
|
*/
|
|
246
273
|
interface OptionsSource {
|
|
247
|
-
|
|
274
|
+
/**
|
|
275
|
+
* Every matching row, as a list — exactly as before a page could be answered, its true
|
|
276
|
+
* total included — or one page of them: `{ options, more, withheld? }`.
|
|
277
|
+
*
|
|
278
|
+
* `more` says rows match beyond these, and the control says so without a number, since
|
|
279
|
+
* nobody counted one. `withheld` counts rows the source matched and cannot hand over — a
|
|
280
|
+
* value a select could not store — because a source withholds and counts rather than
|
|
281
|
+
* filtering silently. A page with any other key, a `more` that is not a boolean or a
|
|
282
|
+
* `withheld` that is not a whole count is refused whole, and the field says its source
|
|
283
|
+
* failed rather than showing a list that looks complete
|
|
284
|
+
* ([0177](../../../docs/decisions/0177-a-source-may-say-its-list-goes-on.md)).
|
|
285
|
+
*/
|
|
286
|
+
resolve(request: OptionsRequest): Promise<RemoteOptionsAnswer$1>;
|
|
248
287
|
/** How long to wait after a keystroke before asking. The control has a default. */
|
|
249
288
|
debounceMs?: number;
|
|
250
|
-
/**
|
|
289
|
+
/**
|
|
290
|
+
* Below this many characters, do not ask at all. The control says so on screen: a
|
|
291
|
+
* typeahead how many to type, and a plain select — whose query is always empty, so it
|
|
292
|
+
* never asks — that its answers are found by searching.
|
|
293
|
+
*/
|
|
251
294
|
minQueryLength?: number;
|
|
252
295
|
/** How many rows to show at once. */
|
|
253
296
|
maxRows?: number;
|
|
@@ -472,6 +515,9 @@ export declare function useRichTextEditorFactory(): RichTextEditorFactory | unde
|
|
|
472
515
|
* **A library cannot make a host render it.** Resuming a draft is the host's call, so
|
|
473
516
|
* this component exists and is documented, and showing it is the deployment's
|
|
474
517
|
* responsibility. `SAFETY-ANALYSIS.md` says so rather than claiming a guarantee.
|
|
518
|
+
*
|
|
519
|
+
* **It speaks the form's language inside the form's `FormancyProvider`**, and English
|
|
520
|
+
* outside one, where there is no engine to take a language from (0171).
|
|
475
521
|
*/
|
|
476
522
|
/** What `resumeDraft` reports. Structural, so a host need not import a type. */
|
|
477
523
|
interface ResumeMigration {
|
|
@@ -489,5 +535,5 @@ interface ResumeNoticeProps {
|
|
|
489
535
|
}
|
|
490
536
|
export declare function ResumeNotice({ migration, labels }: ResumeNoticeProps): ReactElement | null;
|
|
491
537
|
//#endregion
|
|
492
|
-
export type { ErrorSummaryProps, FieldBinding, FieldComponent, FieldComponentProps, FormancyFormProps, OptionsRequest, OptionsSource, OptionsSources, Registry, RepeaterBinding, ResumeMigration, ResumeNoticeProps, RichTextEditorFactory, RichTextEditorHandle, RichTextEditorMount, ScanRequest, Scanner, StoredFile, SubmitOutcome, UploadOptions, Uploader, WizardBinding };
|
|
538
|
+
export type { ErrorSummaryProps, FieldBinding, FieldComponent, FieldComponentProps, FormText, FormWordId, FormWordValues, FormWords, FormWordsByLocale, FormancyFormProps, OptionsRequest, OptionsSource, OptionsSources, Registry, RemoteOption, RemoteOptionsAnswer, RemoteOptionsPage, RepeaterBinding, ResumeMigration, ResumeNoticeProps, RichTextEditorFactory, RichTextEditorHandle, RichTextEditorMount, ScanRequest, Scanner, StoredFile, SubmitOutcome, UploadOptions, Uploader, WizardBinding };
|
|
493
539
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/context.tsx","../src/use-field.ts","../src/use-repeater.ts","../src/use-wizard.ts","../src/use-submit.ts","../src/fields/internals.tsx","../src/form.tsx","../src/error-summary.tsx","../src/rich-text.tsx","../src/options-source.ts","../src/scanning.ts","../src/uploads.ts","../src/rich-text-editor.ts","../src/resume-notice.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/context.tsx","../src/use-field.ts","../src/use-repeater.ts","../src/use-wizard.ts","../src/use-submit.ts","../src/fields/internals.tsx","../src/form.tsx","../src/error-summary.tsx","../src/rich-text.tsx","../src/options-source.ts","../src/scanning.ts","../src/uploads.ts","../src/rich-text-editor.ts","../src/resume-notice.tsx"],"mappings":";;;;;wBAsBgB,mBACd,QACA,OACA;EAEA,QAAQ;;;;;;;EAOR,QAAQ;EACR,WAAW;oBACZ,IAAA;wBAsBe,iBAAiB;;;;;;;;;wBAkBjB,eAAe;;;UCvEd,qBAAqB;E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