@xemahq/ui-kernel 0.6.1 → 0.8.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 +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/biome-host/frontend-biome.d.ts +6 -3
- package/dist/lib/biome-host/frontend-biome.d.ts.map +1 -1
- package/dist/lib/biome-host/frontend-biome.js +9 -0
- package/dist/lib/biome-host/frontend-biome.js.map +1 -1
- package/dist/offline/id.d.ts +2 -0
- package/dist/offline/id.d.ts.map +1 -0
- package/dist/offline/id.js +15 -0
- package/dist/offline/id.js.map +1 -0
- package/dist/offline/index.d.ts +9 -0
- package/dist/offline/index.d.ts.map +1 -0
- package/dist/offline/index.js +26 -0
- package/dist/offline/index.js.map +1 -0
- package/dist/offline/mutation.d.ts +15 -0
- package/dist/offline/mutation.d.ts.map +1 -0
- package/dist/offline/mutation.js +37 -0
- package/dist/offline/mutation.js.map +1 -0
- package/dist/offline/offline-status-badge.d.ts +7 -0
- package/dist/offline/offline-status-badge.d.ts.map +1 -0
- package/dist/offline/offline-status-badge.js +21 -0
- package/dist/offline/offline-status-badge.js.map +1 -0
- package/dist/offline/online-controller.d.ts +18 -0
- package/dist/offline/online-controller.d.ts.map +1 -0
- package/dist/offline/online-controller.js +79 -0
- package/dist/offline/online-controller.js.map +1 -0
- package/dist/offline/outbox.d.ts +57 -0
- package/dist/offline/outbox.d.ts.map +1 -0
- package/dist/offline/outbox.js +257 -0
- package/dist/offline/outbox.js.map +1 -0
- package/dist/offline/react.d.ts +13 -0
- package/dist/offline/react.d.ts.map +1 -0
- package/dist/offline/react.js +42 -0
- package/dist/offline/react.js.map +1 -0
- package/dist/offline/storage.d.ts +22 -0
- package/dist/offline/storage.d.ts.map +1 -0
- package/dist/offline/storage.js +90 -0
- package/dist/offline/storage.js.map +1 -0
- package/dist/offline/types.d.ts +38 -0
- package/dist/offline/types.d.ts.map +1 -0
- package/dist/offline/types.js +11 -0
- package/dist/offline/types.js.map +1 -0
- package/dist/ui/branding/app-branding-provider.d.ts +1 -1
- package/dist/ui/branding/app-branding-provider.d.ts.map +1 -1
- package/dist/ui/capture/document-preview.d.ts +12 -0
- package/dist/ui/capture/document-preview.d.ts.map +1 -0
- package/dist/ui/capture/document-preview.js +31 -0
- package/dist/ui/capture/document-preview.js.map +1 -0
- package/dist/ui/capture/field-spec-to-zod.d.ts +5 -0
- package/dist/ui/capture/field-spec-to-zod.d.ts.map +1 -0
- package/dist/ui/capture/field-spec-to-zod.js +79 -0
- package/dist/ui/capture/field-spec-to-zod.js.map +1 -0
- package/dist/ui/capture/field-spec.d.ts +54 -0
- package/dist/ui/capture/field-spec.d.ts.map +1 -0
- package/dist/ui/capture/field-spec.js +62 -0
- package/dist/ui/capture/field-spec.js.map +1 -0
- package/dist/ui/capture/index.d.ts +11 -0
- package/dist/ui/capture/index.d.ts.map +1 -0
- package/dist/ui/capture/index.js +31 -0
- package/dist/ui/capture/index.js.map +1 -0
- package/dist/ui/capture/schema-field-input.d.ts +20 -0
- package/dist/ui/capture/schema-field-input.d.ts.map +1 -0
- package/dist/ui/capture/schema-field-input.js +127 -0
- package/dist/ui/capture/schema-field-input.js.map +1 -0
- package/dist/ui/capture/schema-form.d.ts +18 -0
- package/dist/ui/capture/schema-form.d.ts.map +1 -0
- package/dist/ui/capture/schema-form.js +26 -0
- package/dist/ui/capture/schema-form.js.map +1 -0
- package/dist/ui/capture/use-prefill.d.ts +18 -0
- package/dist/ui/capture/use-prefill.d.ts.map +1 -0
- package/dist/ui/capture/use-prefill.js +94 -0
- package/dist/ui/capture/use-prefill.js.map +1 -0
- package/dist/ui/capture/use-schema-validation.d.ts +11 -0
- package/dist/ui/capture/use-schema-validation.d.ts.map +1 -0
- package/dist/ui/capture/use-schema-validation.js +69 -0
- package/dist/ui/capture/use-schema-validation.js.map +1 -0
- package/dist/ui/capture/use-wizard.d.ts +28 -0
- package/dist/ui/capture/use-wizard.d.ts.map +1 -0
- package/dist/ui/capture/use-wizard.js +63 -0
- package/dist/ui/capture/use-wizard.js.map +1 -0
- package/dist/ui/capture/value-format.d.ts +4 -0
- package/dist/ui/capture/value-format.d.ts.map +1 -0
- package/dist/ui/capture/value-format.js +23 -0
- package/dist/ui/capture/value-format.js.map +1 -0
- package/dist/ui/capture/wizard.d.ts +19 -0
- package/dist/ui/capture/wizard.d.ts.map +1 -0
- package/dist/ui/capture/wizard.js +34 -0
- package/dist/ui/capture/wizard.js.map +1 -0
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +1 -0
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/primitives/badge.d.ts +1 -1
- package/dist/ui/primitives/button.d.ts +1 -1
- package/dist/ui/primitives/sheet.d.ts +1 -1
- package/package.json +4 -3
- package/src/index.ts +9 -0
- package/src/lib/biome-host/define-web-biome.spec.ts +221 -0
- package/src/lib/biome-host/frontend-biome.ts +32 -5
- package/src/offline/id.ts +16 -0
- package/src/offline/index.ts +52 -0
- package/src/offline/mutation.ts +75 -0
- package/src/offline/offline-status-badge.tsx +51 -0
- package/src/offline/online-controller.ts +105 -0
- package/src/offline/outbox.test.ts +156 -0
- package/src/offline/outbox.ts +344 -0
- package/src/offline/react.tsx +71 -0
- package/src/offline/storage.ts +107 -0
- package/src/offline/types.ts +77 -0
- package/src/ui/branding/app-branding-provider.tsx +1 -1
- package/src/ui/capture/document-preview.tsx +101 -0
- package/src/ui/capture/field-spec-to-zod.test.ts +81 -0
- package/src/ui/capture/field-spec-to-zod.ts +104 -0
- package/src/ui/capture/field-spec.test.ts +49 -0
- package/src/ui/capture/field-spec.ts +181 -0
- package/src/ui/capture/index.ts +43 -0
- package/src/ui/capture/schema-field-input.tsx +314 -0
- package/src/ui/capture/schema-form.tsx +108 -0
- package/src/ui/capture/use-prefill.ts +150 -0
- package/src/ui/capture/use-schema-validation.ts +113 -0
- package/src/ui/capture/use-wizard.ts +134 -0
- package/src/ui/capture/value-format.ts +22 -0
- package/src/ui/capture/wizard.tsx +100 -0
- package/src/ui/index.ts +3 -0
- package/src/lib/biome-host/define-web-biome.test.js +0 -93
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
+
// SchemaFieldInput — one typed input per CaptureFieldType
|
|
3
|
+
//
|
|
4
|
+
// Mirrors app-forge-web's `FieldInput` (the 10 typed inputs) using ui-kernel
|
|
5
|
+
// primitives, and ADDS the `object` (nested group) and `list` (repeatable
|
|
6
|
+
// items) composites. `reference` is source-agnostic here: it defaults to a text
|
|
7
|
+
// input, but a caller can inject a picker via `renderReference` (that is the
|
|
8
|
+
// seam app-forge uses to plug its record-backed `ReferenceSelect`).
|
|
9
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
10
|
+
import { Plus, Trash2 } from 'lucide-react';
|
|
11
|
+
import { useCallback, useRef, useState, type ReactNode } from 'react';
|
|
12
|
+
|
|
13
|
+
import { cn } from '../cn';
|
|
14
|
+
import { Button } from '../primitives/button';
|
|
15
|
+
import { Checkbox } from '../primitives/checkbox';
|
|
16
|
+
import { Input } from '../primitives/input';
|
|
17
|
+
import { Label } from '../primitives/label';
|
|
18
|
+
import { Textarea } from '../primitives/textarea';
|
|
19
|
+
|
|
20
|
+
import { CaptureFieldType, type CaptureFieldSpec, type CaptureValues } from './field-spec';
|
|
21
|
+
import { asString } from './value-format';
|
|
22
|
+
|
|
23
|
+
const SELECT_CLASS =
|
|
24
|
+
'mt-1 flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-body-1 text-foreground ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50';
|
|
25
|
+
|
|
26
|
+
/** Optional override for the `reference` field type (record-backed picker). */
|
|
27
|
+
export type RenderReference = (args: {
|
|
28
|
+
readonly field: CaptureFieldSpec;
|
|
29
|
+
readonly value: unknown;
|
|
30
|
+
readonly onChange: (value: unknown) => void;
|
|
31
|
+
readonly disabled?: boolean;
|
|
32
|
+
readonly inputId: string;
|
|
33
|
+
}) => ReactNode;
|
|
34
|
+
|
|
35
|
+
export interface SchemaFieldInputProps {
|
|
36
|
+
readonly field: CaptureFieldSpec;
|
|
37
|
+
readonly value: unknown;
|
|
38
|
+
readonly onChange: (value: unknown) => void;
|
|
39
|
+
readonly disabled?: boolean;
|
|
40
|
+
/** Dot-path prefix for nested/list item fields (labels/ids stay unique). */
|
|
41
|
+
readonly path: string;
|
|
42
|
+
/** Per-field errors keyed by dot-path (from `useSchemaValidation` or server). */
|
|
43
|
+
readonly errors?: Readonly<Record<string, string>>;
|
|
44
|
+
readonly renderReference?: RenderReference;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function SchemaFieldInput(props: SchemaFieldInputProps) {
|
|
48
|
+
const { field, value, onChange, disabled, path, renderReference } = props;
|
|
49
|
+
const inputId = `field-${path}`;
|
|
50
|
+
|
|
51
|
+
switch (field.type) {
|
|
52
|
+
case CaptureFieldType.Text:
|
|
53
|
+
return <Textarea id={inputId} value={asString(value)} onChange={(e) => onChange(e.target.value)} disabled={disabled} rows={4} placeholder={field.placeholder} />;
|
|
54
|
+
case CaptureFieldType.Number:
|
|
55
|
+
return (
|
|
56
|
+
<Input
|
|
57
|
+
id={inputId}
|
|
58
|
+
type="number"
|
|
59
|
+
value={asString(value)}
|
|
60
|
+
onChange={(e) => onChange(e.target.value === '' ? '' : Number(e.target.value))}
|
|
61
|
+
disabled={disabled}
|
|
62
|
+
placeholder={field.placeholder}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
case CaptureFieldType.Decimal:
|
|
66
|
+
// NUMERIC carried verbatim as text — never Number()-coerced (precision).
|
|
67
|
+
return <Input id={inputId} type="text" inputMode="decimal" value={asString(value)} onChange={(e) => onChange(e.target.value)} disabled={disabled} placeholder={field.placeholder ?? '0.00'} />;
|
|
68
|
+
case CaptureFieldType.User:
|
|
69
|
+
return <Input id={inputId} value={asString(value)} onChange={(e) => onChange(e.target.value)} disabled={disabled} placeholder={field.placeholder ?? 'subject id'} />;
|
|
70
|
+
case CaptureFieldType.Boolean:
|
|
71
|
+
return (
|
|
72
|
+
<div className="mt-1">
|
|
73
|
+
<Checkbox id={inputId} checked={value === true} onCheckedChange={(checked) => onChange(checked === true)} disabled={disabled} />
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
case CaptureFieldType.Date:
|
|
77
|
+
return <Input id={inputId} type="date" value={asString(value)} onChange={(e) => onChange(e.target.value)} disabled={disabled} />;
|
|
78
|
+
case CaptureFieldType.Datetime:
|
|
79
|
+
return <Input id={inputId} type="datetime-local" value={asString(value)} onChange={(e) => onChange(e.target.value)} disabled={disabled} />;
|
|
80
|
+
case CaptureFieldType.Enum:
|
|
81
|
+
return (
|
|
82
|
+
<select id={inputId} className={SELECT_CLASS} value={asString(value)} onChange={(e) => onChange(e.target.value)} disabled={disabled}>
|
|
83
|
+
<option value="">— select —</option>
|
|
84
|
+
{(field.enumValues ?? []).map((v) => (
|
|
85
|
+
<option key={v} value={v}>
|
|
86
|
+
{v}
|
|
87
|
+
</option>
|
|
88
|
+
))}
|
|
89
|
+
</select>
|
|
90
|
+
);
|
|
91
|
+
case CaptureFieldType.Reference:
|
|
92
|
+
return renderReference ? (
|
|
93
|
+
<>{renderReference({ field, value, onChange, disabled, inputId })}</>
|
|
94
|
+
) : (
|
|
95
|
+
<Input id={inputId} value={asString(value)} onChange={(e) => onChange(e.target.value)} disabled={disabled} placeholder={field.placeholder ?? 'reference id'} />
|
|
96
|
+
);
|
|
97
|
+
case CaptureFieldType.Object:
|
|
98
|
+
return <ObjectInput {...props} />;
|
|
99
|
+
case CaptureFieldType.List:
|
|
100
|
+
return <ListInput {...props} />;
|
|
101
|
+
case CaptureFieldType.Image:
|
|
102
|
+
case CaptureFieldType.File:
|
|
103
|
+
return <MediaFieldInput {...props} />;
|
|
104
|
+
case CaptureFieldType.Audio:
|
|
105
|
+
return <AudioFieldInput {...props} />;
|
|
106
|
+
// string (and any unknown) — plain single-line input.
|
|
107
|
+
default:
|
|
108
|
+
return <Input id={inputId} value={asString(value)} onChange={(e) => onChange(e.target.value)} disabled={disabled} placeholder={field.placeholder} />;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const FILE_INPUT_CLASS =
|
|
113
|
+
'block w-full text-body-2 text-foreground file:mr-3 file:rounded-md file:border-0 file:bg-secondary file:px-3 file:py-1.5 file:text-body-2 file:text-secondary-foreground hover:file:bg-secondary/80 disabled:cursor-not-allowed disabled:opacity-50';
|
|
114
|
+
|
|
115
|
+
/** Read a File/Blob as a base64 data-URL (JSON-serializable, offline-safe). */
|
|
116
|
+
function readAsDataUrl(file: Blob, onDone: (dataUrl: string) => void): void {
|
|
117
|
+
const reader = new FileReader();
|
|
118
|
+
reader.onload = () =>
|
|
119
|
+
onDone(typeof reader.result === 'string' ? reader.result : '');
|
|
120
|
+
reader.readAsDataURL(file);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* `image`/`file` capture. On mobile, `field.capture` makes an image field open
|
|
125
|
+
* the camera directly. The value is a data-URL so it stays JSON-serializable and
|
|
126
|
+
* flows unchanged through the record model + offline outbox.
|
|
127
|
+
*/
|
|
128
|
+
function MediaFieldInput({ field, value, onChange, disabled, path }: SchemaFieldInputProps) {
|
|
129
|
+
const inputId = `field-${path}`;
|
|
130
|
+
const current = asString(value);
|
|
131
|
+
const isImage = field.type === CaptureFieldType.Image;
|
|
132
|
+
const accept = field.accept ?? (isImage ? 'image/*' : undefined);
|
|
133
|
+
return (
|
|
134
|
+
<div className="mt-1 space-y-2">
|
|
135
|
+
<input
|
|
136
|
+
id={inputId}
|
|
137
|
+
type="file"
|
|
138
|
+
className={FILE_INPUT_CLASS}
|
|
139
|
+
disabled={disabled}
|
|
140
|
+
{...(accept ? { accept } : {})}
|
|
141
|
+
{...(field.capture ? { capture: field.capture } : {})}
|
|
142
|
+
onChange={(e) => {
|
|
143
|
+
const file = e.target.files?.[0];
|
|
144
|
+
if (file) {
|
|
145
|
+
readAsDataUrl(file, onChange);
|
|
146
|
+
}
|
|
147
|
+
}}
|
|
148
|
+
/>
|
|
149
|
+
{current ? (
|
|
150
|
+
<div className="flex items-center gap-2">
|
|
151
|
+
{isImage && current.startsWith('data:image') ? (
|
|
152
|
+
<img src={current} alt={field.label} className="max-h-32 rounded-md border border-input" />
|
|
153
|
+
) : (
|
|
154
|
+
<span className="truncate text-body-2 text-muted-foreground">Attached</span>
|
|
155
|
+
)}
|
|
156
|
+
<Button type="button" variant="ghost" size="sm" onClick={() => onChange('')} disabled={disabled}>
|
|
157
|
+
Clear
|
|
158
|
+
</Button>
|
|
159
|
+
</div>
|
|
160
|
+
) : null}
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* `audio` capture — records a voice memo via MediaRecorder and stores it as a
|
|
167
|
+
* data-URL. Browser APIs are touched only inside the record handler (SSR-safe).
|
|
168
|
+
*/
|
|
169
|
+
function AudioFieldInput({ value, onChange, disabled, path }: SchemaFieldInputProps) {
|
|
170
|
+
const inputId = `field-${path}`;
|
|
171
|
+
const current = asString(value);
|
|
172
|
+
const [recording, setRecording] = useState(false);
|
|
173
|
+
const [error, setError] = useState<string | null>(null);
|
|
174
|
+
const recorderRef = useRef<MediaRecorder | null>(null);
|
|
175
|
+
const chunksRef = useRef<Blob[]>([]);
|
|
176
|
+
|
|
177
|
+
const start = useCallback(async () => {
|
|
178
|
+
setError(null);
|
|
179
|
+
try {
|
|
180
|
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
|
181
|
+
const recorder = new MediaRecorder(stream);
|
|
182
|
+
chunksRef.current = [];
|
|
183
|
+
recorder.ondataavailable = (e) => {
|
|
184
|
+
if (e.data.size > 0) {
|
|
185
|
+
chunksRef.current.push(e.data);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
recorder.onstop = () => {
|
|
189
|
+
for (const track of stream.getTracks()) {
|
|
190
|
+
track.stop();
|
|
191
|
+
}
|
|
192
|
+
readAsDataUrl(
|
|
193
|
+
new Blob(chunksRef.current, { type: recorder.mimeType || 'audio/webm' }),
|
|
194
|
+
onChange,
|
|
195
|
+
);
|
|
196
|
+
};
|
|
197
|
+
recorderRef.current = recorder;
|
|
198
|
+
recorder.start();
|
|
199
|
+
setRecording(true);
|
|
200
|
+
} catch {
|
|
201
|
+
setError('Microphone unavailable or permission denied.');
|
|
202
|
+
}
|
|
203
|
+
}, [onChange]);
|
|
204
|
+
|
|
205
|
+
const stop = useCallback(() => {
|
|
206
|
+
recorderRef.current?.stop();
|
|
207
|
+
recorderRef.current = null;
|
|
208
|
+
setRecording(false);
|
|
209
|
+
}, []);
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<div className="mt-1 space-y-2">
|
|
213
|
+
<div className="flex items-center gap-2">
|
|
214
|
+
{recording ? (
|
|
215
|
+
<Button type="button" variant="secondary" size="sm" onClick={stop} disabled={disabled}>
|
|
216
|
+
Stop
|
|
217
|
+
</Button>
|
|
218
|
+
) : (
|
|
219
|
+
<Button type="button" variant="secondary" size="sm" onClick={() => void start()} disabled={disabled}>
|
|
220
|
+
{current ? 'Re-record' : 'Record'}
|
|
221
|
+
</Button>
|
|
222
|
+
)}
|
|
223
|
+
{current ? (
|
|
224
|
+
<Button type="button" variant="ghost" size="sm" onClick={() => onChange('')} disabled={disabled}>
|
|
225
|
+
Clear
|
|
226
|
+
</Button>
|
|
227
|
+
) : null}
|
|
228
|
+
</div>
|
|
229
|
+
{error ? <p className="text-body-2 text-destructive">{error}</p> : null}
|
|
230
|
+
{current && !recording ? <audio id={inputId} controls src={current} className="w-full" /> : null}
|
|
231
|
+
</div>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Renders one label + input + error block for a nested field. */
|
|
236
|
+
function NestedField(props: SchemaFieldInputProps) {
|
|
237
|
+
const { field, path, errors } = props;
|
|
238
|
+
const error = errors?.[path];
|
|
239
|
+
return (
|
|
240
|
+
<div>
|
|
241
|
+
<Label htmlFor={`field-${path}`}>
|
|
242
|
+
{field.label}
|
|
243
|
+
{field.required ? <span className="text-destructive"> *</span> : null}
|
|
244
|
+
</Label>
|
|
245
|
+
{field.description ? <p className="mb-1 text-caption text-ink-3">{field.description}</p> : null}
|
|
246
|
+
<SchemaFieldInput {...props} />
|
|
247
|
+
{error ? <p className="mt-1 text-caption text-destructive">{error}</p> : null}
|
|
248
|
+
</div>
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function ObjectInput({ field, value, onChange, disabled, path, errors, renderReference }: SchemaFieldInputProps) {
|
|
253
|
+
const record = (value && typeof value === 'object' && !Array.isArray(value) ? value : {}) as CaptureValues;
|
|
254
|
+
const fields = field.fields ?? [];
|
|
255
|
+
return (
|
|
256
|
+
<div className="mt-1 space-y-3 rounded-lg border border-rule bg-paper-elev/40 p-3">
|
|
257
|
+
{fields.map((child) => (
|
|
258
|
+
<NestedField
|
|
259
|
+
key={child.key}
|
|
260
|
+
field={child}
|
|
261
|
+
value={record[child.key]}
|
|
262
|
+
onChange={(v) => onChange({ ...record, [child.key]: v })}
|
|
263
|
+
disabled={disabled}
|
|
264
|
+
path={`${path}.${child.key}`}
|
|
265
|
+
errors={errors}
|
|
266
|
+
renderReference={renderReference}
|
|
267
|
+
/>
|
|
268
|
+
))}
|
|
269
|
+
</div>
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function ListInput({ field, value, onChange, disabled, path, errors, renderReference }: SchemaFieldInputProps) {
|
|
274
|
+
const items = (Array.isArray(value) ? value : []) as CaptureValues[];
|
|
275
|
+
const fields = field.fields ?? [];
|
|
276
|
+
const atMax = typeof field.max === 'number' && items.length >= field.max;
|
|
277
|
+
|
|
278
|
+
const setItem = (index: number, next: CaptureValues) => onChange(items.map((it, i) => (i === index ? next : it)));
|
|
279
|
+
const removeItem = (index: number) => onChange(items.filter((_, i) => i !== index));
|
|
280
|
+
const addItem = () => onChange([...items, {}]);
|
|
281
|
+
|
|
282
|
+
return (
|
|
283
|
+
<div className="mt-1 space-y-2">
|
|
284
|
+
{items.map((item, index) => (
|
|
285
|
+
<div key={index} className="relative space-y-3 rounded-lg border border-rule bg-paper-elev/40 p-3">
|
|
286
|
+
<div className="flex items-center justify-between">
|
|
287
|
+
<span className="text-caption font-medium text-ink-3">
|
|
288
|
+
{field.label} #{index + 1}
|
|
289
|
+
</span>
|
|
290
|
+
<Button type="button" variant="ghost" size="icon" onClick={() => removeItem(index)} disabled={disabled} aria-label={`Remove ${field.label} ${index + 1}`}>
|
|
291
|
+
<Trash2 className="h-4 w-4" />
|
|
292
|
+
</Button>
|
|
293
|
+
</div>
|
|
294
|
+
{fields.map((child) => (
|
|
295
|
+
<NestedField
|
|
296
|
+
key={child.key}
|
|
297
|
+
field={child}
|
|
298
|
+
value={item[child.key]}
|
|
299
|
+
onChange={(v) => setItem(index, { ...item, [child.key]: v })}
|
|
300
|
+
disabled={disabled}
|
|
301
|
+
path={`${path}.${index}.${child.key}`}
|
|
302
|
+
errors={errors}
|
|
303
|
+
renderReference={renderReference}
|
|
304
|
+
/>
|
|
305
|
+
))}
|
|
306
|
+
</div>
|
|
307
|
+
))}
|
|
308
|
+
<Button type="button" variant="outline" size="sm" onClick={addItem} disabled={disabled || atMax} className={cn(items.length === 0 && 'w-full')}>
|
|
309
|
+
<Plus className="mr-1.5 h-3.5 w-3.5" />
|
|
310
|
+
Add {field.label}
|
|
311
|
+
</Button>
|
|
312
|
+
</div>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
+
// <SchemaForm> — the ONE kernel schema→form renderer
|
|
3
|
+
//
|
|
4
|
+
// Consolidates the three parallel schema→form implementations (app-forge-web's
|
|
5
|
+
// RecordForm/FieldInput, the pipelines with-schema-form, the rjsf install
|
|
6
|
+
// wizard) into a single reusable primitive. Give it a flat `fields` list OR
|
|
7
|
+
// titled `sections`; it renders one typed input per field (10 scalar types +
|
|
8
|
+
// nested `object` + repeatable `list`), inline per-field errors, and an "AI
|
|
9
|
+
// suggested" badge for machine-prefilled fields.
|
|
10
|
+
//
|
|
11
|
+
// Controlled: owns no value state — `values` in, `onChange` out. Pair it with
|
|
12
|
+
// `useSchemaValidation` for live errors and `usePrefill` for suggestions.
|
|
13
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
14
|
+
import { Sparkles } from 'lucide-react';
|
|
15
|
+
import { type ReactNode } from 'react';
|
|
16
|
+
|
|
17
|
+
import { cn } from '../cn';
|
|
18
|
+
import { Badge } from '../primitives/badge';
|
|
19
|
+
import { Label } from '../primitives/label';
|
|
20
|
+
|
|
21
|
+
import { type CaptureFieldSpec, type CaptureSchema, type CaptureSection, type CaptureValues, toSections } from './field-spec';
|
|
22
|
+
import { SchemaFieldInput, type RenderReference } from './schema-field-input';
|
|
23
|
+
|
|
24
|
+
export interface SchemaFormProps {
|
|
25
|
+
/** Flat schema. Mutually exclusive with `sections`. */
|
|
26
|
+
readonly fields?: readonly CaptureFieldSpec[];
|
|
27
|
+
/** Sectioned schema. Mutually exclusive with `fields`. */
|
|
28
|
+
readonly sections?: readonly CaptureSection[];
|
|
29
|
+
/** Pre-built schema object (either face). Lowest precedence. */
|
|
30
|
+
readonly schema?: CaptureSchema;
|
|
31
|
+
readonly values: CaptureValues;
|
|
32
|
+
readonly onChange: (values: CaptureValues) => void;
|
|
33
|
+
/** Per-field errors keyed by dot-path (from `useSchemaValidation` / server). */
|
|
34
|
+
readonly errors?: Readonly<Record<string, string>>;
|
|
35
|
+
/** Field keys to badge as machine-suggested (from `usePrefill`). */
|
|
36
|
+
readonly suggestedKeys?: ReadonlySet<string> | readonly string[];
|
|
37
|
+
readonly disabled?: boolean;
|
|
38
|
+
/** Inject a record-backed picker for `reference` fields. */
|
|
39
|
+
readonly renderReference?: RenderReference;
|
|
40
|
+
/** Show section titles (default true when a section has a title). */
|
|
41
|
+
readonly className?: string;
|
|
42
|
+
/** Optional slot rendered after the fields (e.g. a submit bar). */
|
|
43
|
+
readonly footer?: ReactNode;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function toSet(keys: SchemaFormProps['suggestedKeys']): ReadonlySet<string> {
|
|
47
|
+
if (!keys) return new Set();
|
|
48
|
+
return keys instanceof Set ? keys : new Set(keys as readonly string[]);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @example
|
|
53
|
+
* const [values, setValues] = useState({});
|
|
54
|
+
* const { errors } = useSchemaValidation(fields, values);
|
|
55
|
+
* <SchemaForm fields={fields} values={values} onChange={setValues} errors={errors} />
|
|
56
|
+
*/
|
|
57
|
+
export function SchemaForm({ fields, sections, schema, values, onChange, errors, suggestedKeys, disabled, renderReference, className, footer }: SchemaFormProps) {
|
|
58
|
+
const resolved: readonly CaptureSection[] = toSections(sections ?? (fields ? fields : schema) ?? []);
|
|
59
|
+
const suggested = toSet(suggestedKeys);
|
|
60
|
+
|
|
61
|
+
const setField = (key: string, value: unknown) => onChange({ ...values, [key]: value });
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div className={cn('space-y-6', className)}>
|
|
65
|
+
{resolved.map((section) => (
|
|
66
|
+
<fieldset key={section.key} className="space-y-3 border-0 p-0" disabled={disabled}>
|
|
67
|
+
{section.title ? (
|
|
68
|
+
<legend className="mb-1 text-subtitle font-semibold text-ink">
|
|
69
|
+
{section.title}
|
|
70
|
+
{section.description ? <span className="mt-0.5 block text-caption font-normal text-ink-3">{section.description}</span> : null}
|
|
71
|
+
</legend>
|
|
72
|
+
) : null}
|
|
73
|
+
{section.fields.map((field) => {
|
|
74
|
+
const error = errors?.[field.key];
|
|
75
|
+
const isSuggested = suggested.has(field.key);
|
|
76
|
+
return (
|
|
77
|
+
<div key={field.key}>
|
|
78
|
+
<div className="flex items-center gap-2">
|
|
79
|
+
<Label htmlFor={`field-${field.key}`}>
|
|
80
|
+
{field.label}
|
|
81
|
+
{field.required ? <span className="text-destructive"> *</span> : null}
|
|
82
|
+
</Label>
|
|
83
|
+
{isSuggested ? (
|
|
84
|
+
<Badge variant="outline" className="gap-1 border-primary/30 bg-primary/10 px-1.5 py-0 text-caption text-primary">
|
|
85
|
+
<Sparkles className="h-3 w-3" /> AI suggested
|
|
86
|
+
</Badge>
|
|
87
|
+
) : null}
|
|
88
|
+
</div>
|
|
89
|
+
{field.description ? <p className="mb-1 text-caption text-ink-3">{field.description}</p> : null}
|
|
90
|
+
<SchemaFieldInput
|
|
91
|
+
field={field}
|
|
92
|
+
value={values[field.key]}
|
|
93
|
+
onChange={(v) => setField(field.key, v)}
|
|
94
|
+
disabled={disabled}
|
|
95
|
+
path={field.key}
|
|
96
|
+
errors={errors}
|
|
97
|
+
renderReference={renderReference}
|
|
98
|
+
/>
|
|
99
|
+
{error ? <p className="mt-1 text-caption text-destructive">{error}</p> : null}
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
})}
|
|
103
|
+
</fieldset>
|
|
104
|
+
))}
|
|
105
|
+
{footer}
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
+
// usePrefill — field-level pre-fill from an async, source-agnostic default
|
|
3
|
+
// source (AI, prior-context, a template service — the caller supplies it).
|
|
4
|
+
//
|
|
5
|
+
// It populates initial field values WITHOUT clobbering user edits, and tracks
|
|
6
|
+
// which fields were machine-suggested so the UI can badge them. A field the
|
|
7
|
+
// user has touched is never overwritten by a (re)load, and reading a field back
|
|
8
|
+
// after the user edits it clears its "suggested" mark.
|
|
9
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
10
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
11
|
+
|
|
12
|
+
import type { CaptureValues } from './field-spec';
|
|
13
|
+
|
|
14
|
+
export interface UsePrefillOptions<T extends CaptureValues = CaptureValues> {
|
|
15
|
+
/**
|
|
16
|
+
* Async source of default values keyed by field key. Called on mount (unless
|
|
17
|
+
* `enabled` is false) and on `reload()`. May return a partial record — only
|
|
18
|
+
* the keys it returns are considered suggestions.
|
|
19
|
+
*/
|
|
20
|
+
readonly fetchDefaults: () => Promise<Partial<T>>;
|
|
21
|
+
/** Seed values (e.g. an edit form's existing record). Never treated as suggested. */
|
|
22
|
+
readonly initialValues?: T;
|
|
23
|
+
/** Gate the initial fetch (default true). */
|
|
24
|
+
readonly enabled?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface UsePrefillResult<T extends CaptureValues = CaptureValues> {
|
|
28
|
+
readonly values: T;
|
|
29
|
+
/** Set one field (a user edit) — clears its suggested mark. */
|
|
30
|
+
readonly setValue: (key: string, value: unknown) => void;
|
|
31
|
+
/** Replace/patch values (a user edit) — clears suggested marks for changed keys. */
|
|
32
|
+
readonly setValues: (updater: Partial<T> | ((prev: T) => T)) => void;
|
|
33
|
+
/** Keys populated by the default source and NOT yet edited by the user. */
|
|
34
|
+
readonly suggestedKeys: ReadonlySet<string>;
|
|
35
|
+
readonly isSuggested: (key: string) => boolean;
|
|
36
|
+
readonly loading: boolean;
|
|
37
|
+
readonly error: unknown;
|
|
38
|
+
/** Re-run `fetchDefaults`; still respects user-touched keys. */
|
|
39
|
+
readonly reload: () => void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @example
|
|
44
|
+
* const prefill = usePrefill({
|
|
45
|
+
* fetchDefaults: () => api.suggestDefaults(contextId), // → { title: 'Draft', owner: 'me' }
|
|
46
|
+
* initialValues: { title: '', owner: '' },
|
|
47
|
+
* });
|
|
48
|
+
* <SchemaForm
|
|
49
|
+
* fields={fields}
|
|
50
|
+
* values={prefill.values}
|
|
51
|
+
* onChange={prefill.setValues}
|
|
52
|
+
* suggestedKeys={prefill.suggestedKeys} // renders an "AI suggested" badge
|
|
53
|
+
* />
|
|
54
|
+
*/
|
|
55
|
+
export function usePrefill<T extends CaptureValues = CaptureValues>(
|
|
56
|
+
options: UsePrefillOptions<T>,
|
|
57
|
+
): UsePrefillResult<T> {
|
|
58
|
+
const { fetchDefaults, initialValues, enabled = true } = options;
|
|
59
|
+
|
|
60
|
+
const [values, setValuesState] = useState<T>(() => ({ ...(initialValues ?? ({} as T)) }));
|
|
61
|
+
const [suggested, setSuggested] = useState<ReadonlySet<string>>(() => new Set());
|
|
62
|
+
const [loading, setLoading] = useState(false);
|
|
63
|
+
const [error, setError] = useState<unknown>(null);
|
|
64
|
+
|
|
65
|
+
// Keys the user has explicitly touched — a (re)load must never clobber these.
|
|
66
|
+
const touched = useRef<Set<string>>(new Set());
|
|
67
|
+
// Monotonic request id guards against a stale fetch resolving after a newer
|
|
68
|
+
// one (or after user edits) — no timeout-based races.
|
|
69
|
+
const requestId = useRef(0);
|
|
70
|
+
|
|
71
|
+
const setValue = useCallback((key: string, value: unknown) => {
|
|
72
|
+
touched.current.add(key);
|
|
73
|
+
setValuesState((prev) => ({ ...prev, [key]: value }));
|
|
74
|
+
setSuggested((prev) => {
|
|
75
|
+
if (!prev.has(key)) return prev;
|
|
76
|
+
const next = new Set(prev);
|
|
77
|
+
next.delete(key);
|
|
78
|
+
return next;
|
|
79
|
+
});
|
|
80
|
+
}, []);
|
|
81
|
+
|
|
82
|
+
const setValues = useCallback((updater: Partial<T> | ((prev: T) => T)) => {
|
|
83
|
+
setValuesState((prev) => {
|
|
84
|
+
const next = typeof updater === 'function' ? (updater as (p: T) => T)(prev) : { ...prev, ...updater };
|
|
85
|
+
const changed = new Set<string>();
|
|
86
|
+
for (const k of Object.keys(next)) {
|
|
87
|
+
if (next[k] !== prev[k]) {
|
|
88
|
+
touched.current.add(k);
|
|
89
|
+
changed.add(k);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (changed.size > 0) {
|
|
93
|
+
setSuggested((prevSug) => {
|
|
94
|
+
if (![...changed].some((k) => prevSug.has(k))) return prevSug;
|
|
95
|
+
const n = new Set(prevSug);
|
|
96
|
+
for (const k of changed) n.delete(k);
|
|
97
|
+
return n;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return next;
|
|
101
|
+
});
|
|
102
|
+
}, []);
|
|
103
|
+
|
|
104
|
+
const run = useCallback(() => {
|
|
105
|
+
const id = ++requestId.current;
|
|
106
|
+
setLoading(true);
|
|
107
|
+
setError(null);
|
|
108
|
+
void fetchDefaults()
|
|
109
|
+
.then((defaults) => {
|
|
110
|
+
if (id !== requestId.current) return; // superseded — drop
|
|
111
|
+
const applied: string[] = [];
|
|
112
|
+
setValuesState((prev) => {
|
|
113
|
+
const next = { ...prev };
|
|
114
|
+
for (const [key, value] of Object.entries(defaults)) {
|
|
115
|
+
// Only fill keys the user hasn't touched and that are still empty.
|
|
116
|
+
const current = prev[key];
|
|
117
|
+
const isEmpty = current === undefined || current === null || current === '';
|
|
118
|
+
if (!touched.current.has(key) && isEmpty && value !== undefined) {
|
|
119
|
+
(next as CaptureValues)[key] = value;
|
|
120
|
+
applied.push(key);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return next;
|
|
124
|
+
});
|
|
125
|
+
setSuggested((prev) => {
|
|
126
|
+
if (applied.length === 0) return prev;
|
|
127
|
+
const n = new Set(prev);
|
|
128
|
+
for (const k of applied) n.add(k);
|
|
129
|
+
return n;
|
|
130
|
+
});
|
|
131
|
+
})
|
|
132
|
+
.catch((e: unknown) => {
|
|
133
|
+
if (id !== requestId.current) return;
|
|
134
|
+
setError(e);
|
|
135
|
+
})
|
|
136
|
+
.finally(() => {
|
|
137
|
+
if (id === requestId.current) setLoading(false);
|
|
138
|
+
});
|
|
139
|
+
}, [fetchDefaults]);
|
|
140
|
+
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (enabled) run();
|
|
143
|
+
// Run once on mount / when re-enabled; `reload()` is the explicit re-fetch.
|
|
144
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
145
|
+
}, [enabled]);
|
|
146
|
+
|
|
147
|
+
const isSuggested = useCallback((key: string) => suggested.has(key), [suggested]);
|
|
148
|
+
|
|
149
|
+
return { values, setValue, setValues, suggestedKeys: suggested, isSuggested, loading, error, reload: run };
|
|
150
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
+
// useSchemaValidation — client-side validation + "missing info" sweep
|
|
3
|
+
//
|
|
4
|
+
// Runs BEFORE any server round-trip, on every change/blur. Accepts either a
|
|
5
|
+
// hand-written `zod` schema OR a `CaptureFieldSpec[]` / `CaptureSection[]` /
|
|
6
|
+
// `CaptureSchema` (auto-adapted via `fieldSpecToZod`). Returns per-field errors
|
|
7
|
+
// keyed by dot-path plus a deterministic `missingRequired` list so a guided UX
|
|
8
|
+
// can nudge "you still need to fill X" without waiting for a 422.
|
|
9
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
10
|
+
import { useMemo } from 'react';
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
|
|
13
|
+
import { CaptureFieldType, type CaptureFieldSpec, type CaptureSchema, type CaptureSection, type CaptureValues, toFieldList } from './field-spec';
|
|
14
|
+
import { fieldSpecToZod, isEmptyValue } from './field-spec-to-zod';
|
|
15
|
+
|
|
16
|
+
export interface SchemaValidationResult {
|
|
17
|
+
/** First error per field, keyed by dot-path (`tags.0.name`, `address.city`). */
|
|
18
|
+
readonly errors: Readonly<Record<string, string>>;
|
|
19
|
+
/** Dot-paths of required fields still empty — the "missing info" sweep. */
|
|
20
|
+
readonly missingRequired: readonly string[];
|
|
21
|
+
/** True when there are no errors AND nothing required is missing. */
|
|
22
|
+
readonly isValid: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type ValidationInput =
|
|
26
|
+
| z.ZodType
|
|
27
|
+
| CaptureSchema
|
|
28
|
+
| readonly CaptureFieldSpec[]
|
|
29
|
+
| readonly CaptureSection[];
|
|
30
|
+
|
|
31
|
+
function isZodSchema(input: ValidationInput): input is z.ZodType {
|
|
32
|
+
return typeof (input as z.ZodType)?.safeParse === 'function';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Deterministic required sweep over the flat spec list (nested-aware). */
|
|
36
|
+
function sweepMissing(fields: readonly CaptureFieldSpec[], values: CaptureValues, prefix = ''): string[] {
|
|
37
|
+
const missing: string[] = [];
|
|
38
|
+
for (const field of fields) {
|
|
39
|
+
const path = prefix ? `${prefix}.${field.key}` : field.key;
|
|
40
|
+
const value = values?.[field.key];
|
|
41
|
+
if (field.type === CaptureFieldType.Object) {
|
|
42
|
+
if (field.required && isEmptyValue(value)) missing.push(path);
|
|
43
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
44
|
+
missing.push(...sweepMissing(field.fields ?? [], value as CaptureValues, path));
|
|
45
|
+
}
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (field.type === CaptureFieldType.List) {
|
|
49
|
+
if (field.required && isEmptyValue(value)) missing.push(path);
|
|
50
|
+
if (Array.isArray(value)) {
|
|
51
|
+
value.forEach((item, i) => {
|
|
52
|
+
if (item && typeof item === 'object') {
|
|
53
|
+
missing.push(...sweepMissing(field.fields ?? [], item as CaptureValues, `${path}.${i}`));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (field.required && isEmptyValue(value)) missing.push(path);
|
|
60
|
+
}
|
|
61
|
+
return missing;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @example
|
|
66
|
+
* const { errors, missingRequired, isValid } = useSchemaValidation(fields, values);
|
|
67
|
+
* // live under each input:
|
|
68
|
+
* errors['email'] // → 'Email must be a valid address' | undefined
|
|
69
|
+
* missingRequired // → ['email', 'address.city']
|
|
70
|
+
* // gate a wizard step / submit button:
|
|
71
|
+
* <Button disabled={!isValid}>Continue</Button>
|
|
72
|
+
*/
|
|
73
|
+
export function useSchemaValidation(input: ValidationInput, values: CaptureValues): SchemaValidationResult {
|
|
74
|
+
// Field specs (when supplied) drive the deterministic required sweep and the
|
|
75
|
+
// auto-adapted zod schema; a raw zod schema is used as-is.
|
|
76
|
+
const fields = useMemo<readonly CaptureFieldSpec[] | null>(
|
|
77
|
+
() => (isZodSchema(input) ? null : toFieldList(input)),
|
|
78
|
+
[input],
|
|
79
|
+
);
|
|
80
|
+
const schema = useMemo<z.ZodType>(
|
|
81
|
+
() => (isZodSchema(input) ? input : fieldSpecToZod(input)),
|
|
82
|
+
[input],
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
return useMemo<SchemaValidationResult>(() => {
|
|
86
|
+
const errors: Record<string, string> = {};
|
|
87
|
+
const result = schema.safeParse(values);
|
|
88
|
+
if (!result.success) {
|
|
89
|
+
for (const issue of result.error.issues) {
|
|
90
|
+
const path = issue.path.map(String).join('.');
|
|
91
|
+
// First error per path wins (deterministic, matches display order).
|
|
92
|
+
if (!(path in errors)) errors[path] = issue.message;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Deterministic sweep when we have specs; otherwise derive "missing" from
|
|
97
|
+
// zod issues that fired on an empty value (so a bare zod schema still works).
|
|
98
|
+
const missingRequired = fields
|
|
99
|
+
? sweepMissing(fields, values)
|
|
100
|
+
: Object.keys(errors).filter((path) => {
|
|
101
|
+
const segments = path.split('.');
|
|
102
|
+
let cur: unknown = values;
|
|
103
|
+
for (const seg of segments) cur = (cur as CaptureValues | undefined)?.[seg];
|
|
104
|
+
return isEmptyValue(cur);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
errors,
|
|
109
|
+
missingRequired,
|
|
110
|
+
isValid: Object.keys(errors).length === 0 && missingRequired.length === 0,
|
|
111
|
+
};
|
|
112
|
+
}, [schema, fields, values]);
|
|
113
|
+
}
|