@forming/react 0.0.0-stage → 0.1.0-dev.2.2

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.
@@ -0,0 +1,223 @@
1
+ import React from 'react';
2
+ import { JsonNumber, type JsonValue } from '@forming/integrations/lossless-json';
3
+ import type { ChoicePresentation, Extension, Extensions } from '@forming/integrations/extensions';
4
+ import { editorText } from './editors.js';
5
+ export interface Runtime {
6
+ view(): string;
7
+ document(): string;
8
+ dispatch(eventJson: string): string | null;
9
+ }
10
+ type Snapshot = {
11
+ viewJson: string;
12
+ view: View;
13
+ editorErrors: ReadonlySet<string>;
14
+ error: string | null;
15
+ reset: number;
16
+ };
17
+ export interface UploadHost {
18
+ select(owner: string, files: File[]): string;
19
+ retry(owner: string, slot: string): string | null;
20
+ }
21
+ export declare function createController(runtime: Runtime, dispatch?: Runtime['dispatch'], uploads?: UploadHost): {
22
+ document: () => string;
23
+ getSnapshot: () => Snapshot;
24
+ subscribe(listener: () => void): () => void;
25
+ dispose(): void;
26
+ refresh: () => void;
27
+ uploadsAvailable: boolean;
28
+ selectFiles(owner: string, files: File[]): void;
29
+ retryFile(owner: string, slot: string): void;
30
+ editor(id: string, invalid: boolean): void;
31
+ send(event: Record<string, unknown>): boolean;
32
+ };
33
+ export type Controller = ReturnType<typeof createController>;
34
+ interface Node {
35
+ id: string;
36
+ type: string;
37
+ annotations?: {
38
+ package: string;
39
+ export: string;
40
+ values: JsonValue[];
41
+ }[];
42
+ title?: string;
43
+ description?: string;
44
+ placeholder?: string;
45
+ content?: string;
46
+ children?: Node[];
47
+ bind?: string;
48
+ schemaPath?: string;
49
+ structure?: string;
50
+ control?: string;
51
+ itemId?: string;
52
+ columns?: JsonNumber;
53
+ providers?: {
54
+ id: string;
55
+ kind: string;
56
+ }[];
57
+ file?: {
58
+ multiple: boolean;
59
+ accept: string[];
60
+ };
61
+ implicit?: boolean;
62
+ options?: Option[];
63
+ }
64
+ interface State {
65
+ nodeId: string;
66
+ visible: boolean;
67
+ enabled: boolean;
68
+ readonly: boolean;
69
+ required: boolean;
70
+ }
71
+ interface Issue {
72
+ nodeId: string;
73
+ message: string;
74
+ pointer: string;
75
+ code?: string;
76
+ }
77
+ interface Option {
78
+ value: JsonValue;
79
+ label?: string;
80
+ disabled?: boolean;
81
+ status?: string;
82
+ }
83
+ interface Slot {
84
+ site: string;
85
+ operation: string;
86
+ state: string;
87
+ message?: string;
88
+ errorMessage?: string;
89
+ result?: {
90
+ items?: Option[];
91
+ nextCursor?: string | null;
92
+ };
93
+ error?: {
94
+ retryable: boolean;
95
+ };
96
+ }
97
+ interface View {
98
+ status: string;
99
+ data: JsonValue;
100
+ form?: Node;
101
+ errorsRevealed: boolean;
102
+ navigation: {
103
+ currentPage: string | null;
104
+ route?: string[];
105
+ history?: string[];
106
+ };
107
+ texts?: Record<string, {
108
+ content?: string;
109
+ title?: string;
110
+ }>;
111
+ localization?: {
112
+ locale: string;
113
+ direction: 'ltr' | 'rtl';
114
+ renderer?: Partial<RendererText>;
115
+ };
116
+ validation: {
117
+ fieldStates: State[];
118
+ viewStates?: State[];
119
+ issues: Issue[];
120
+ };
121
+ actions: {
122
+ id: string;
123
+ type: string;
124
+ label: string;
125
+ enabled: boolean;
126
+ }[];
127
+ providerState?: {
128
+ slots: Slot[];
129
+ };
130
+ submissionIntent?: {
131
+ state: string;
132
+ };
133
+ uploadState?: {
134
+ fields: {
135
+ owner: string;
136
+ node: string;
137
+ retired: boolean;
138
+ ready: boolean;
139
+ reselect: JsonNumber;
140
+ engine: {
141
+ slots: {
142
+ id: string;
143
+ file: {
144
+ name: string;
145
+ };
146
+ committed: boolean;
147
+ state: string;
148
+ error?: {
149
+ retryable?: boolean;
150
+ };
151
+ }[];
152
+ };
153
+ }[];
154
+ };
155
+ }
156
+ declare const defaultText: {
157
+ clear: string;
158
+ setNull: string;
159
+ create: string;
160
+ add: string;
161
+ remove: string;
162
+ up: string;
163
+ down: string;
164
+ search: string;
165
+ more: string;
166
+ retry: string;
167
+ waiting: string;
168
+ unavailable: string;
169
+ choose: string;
170
+ chooseMany: string;
171
+ invalid: string;
172
+ unsupported: string;
173
+ nullValue: string;
174
+ shownAs: string;
175
+ reselect: string;
176
+ dismiss: string;
177
+ uploading: string;
178
+ verified: string;
179
+ uploadFailed: string;
180
+ uploadNotReady: string;
181
+ issueSingle: string;
182
+ issueCount: string;
183
+ issueFirst: string;
184
+ step: string;
185
+ next: string;
186
+ back: string;
187
+ pressEnter: string;
188
+ counter: string;
189
+ };
190
+ declare const additionalText: {
191
+ trueValue: string;
192
+ falseValue: string;
193
+ accept: string;
194
+ formUnavailable: string;
195
+ };
196
+ export type RendererText = typeof defaultText & typeof additionalText & typeof editorText;
197
+ export type { ChoiceContext, ChoicePresentation, FieldDrawing, Presentation } from '@forming/integrations/extensions';
198
+ /** A ready-made plugin for selectable sections with a heading and body text.
199
+ * Field keys are answer pointers (e.g. /plan); values stay exact JSON values.
200
+ * Register it with createExtensions like any other plugin.
201
+ */
202
+ export declare function choiceCards({ identity, fields, }: {
203
+ identity: string;
204
+ fields: Record<string, readonly (ChoicePresentation & {
205
+ value: JsonValue;
206
+ })[]>;
207
+ }): Extension;
208
+ export interface FormingFormProps {
209
+ controller: Controller;
210
+ /** The same createExtensions registry used for the runtime; renderers read its presentation hooks. */
211
+ extensions?: Pick<Extensions, 'presentation'>;
212
+ text?: Partial<RendererText>;
213
+ className?: string;
214
+ /** Presentation only. Authored pages and runtime navigation remain authoritative. */
215
+ presentation?: 'embedded' | 'focused';
216
+ /**
217
+ * 'standard' (default) shows respondent-facing controls only. 'exact' adds the
218
+ * data-level controls: explicit null, empty lists, the portable date/time text
219
+ * and locale echoes of values that already read the same.
220
+ */
221
+ detail?: 'standard' | 'exact';
222
+ }
223
+ export declare function FormingForm({ controller, text: overrides, className, presentation, detail, extensions, }: FormingFormProps): React.JSX.Element;