@lucas-barake/effect-form-react 0.11.0 → 0.13.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.
@@ -1,30 +1,33 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { RegistryContext, useAtom, useAtomSet, useAtomSubscribe, useAtomValue } from "@effect-atom/atom-react";
2
+ import { RegistryContext, useAtom, useAtomMount, useAtomSet, useAtomSubscribe, useAtomValue } from "@effect-atom/atom-react";
3
+ import * as Atom from "@effect-atom/atom/Atom";
3
4
  import { Field, FormAtoms, Mode, Validation } from "@lucas-barake/effect-form";
4
- import { getNestedValue, isPathOrParentDirty, isPathUnderRoot } from "@lucas-barake/effect-form/Path";
5
+ import { getNestedValue, isPathOrParentDirty } from "@lucas-barake/effect-form/Path";
5
6
  import * as Cause from "effect/Cause";
7
+ import * as Layer from "effect/Layer";
6
8
  import * as Option from "effect/Option";
7
9
  import * as ParseResult from "effect/ParseResult";
10
+ import * as Predicate from "effect/Predicate";
8
11
  import * as AST from "effect/SchemaAST";
9
12
  import * as React from "react";
10
13
  import { createContext, useContext } from "react";
11
14
  import { useDebounced } from "./internal/use-debounced.js";
15
+ const isFieldBundle = x => Predicate.isTagged(x, "FieldBundle");
12
16
  const ArrayItemContext = /*#__PURE__*/createContext(null);
13
17
  const AutoSubmitContext = /*#__PURE__*/createContext(null);
14
- const makeFieldComponent = (fieldKey, fieldDef, crossFieldErrorsAtom, submitCountAtom, dirtyFieldsAtom, parsedMode, getOrCreateValidationAtom, getOrCreateFieldAtoms, Component) => {
18
+ const makeFieldComponent = (fieldKey, fieldDef, errorsAtom, submitCountAtom, dirtyFieldsAtom, parsedMode, getOrCreateValidationAtom, getOrCreateFieldAtoms, Component) => {
15
19
  const FieldComponent = extraProps => {
16
20
  const arrayCtx = useContext(ArrayItemContext);
17
21
  const autoSubmitOnBlur = useContext(AutoSubmitContext);
18
22
  const fieldPath = arrayCtx ? `${arrayCtx.parentPath}.${fieldKey}` : fieldKey;
19
23
  const {
20
- crossFieldErrorAtom,
24
+ errorAtom,
21
25
  touchedAtom,
22
26
  valueAtom
23
27
  } = React.useMemo(() => getOrCreateFieldAtoms(fieldPath), [fieldPath]);
24
28
  const [value, setValue] = useAtom(valueAtom);
25
29
  const [isTouched, setTouched] = useAtom(touchedAtom);
26
- const crossFieldError = useAtomValue(crossFieldErrorAtom);
27
- const setCrossFieldErrors = useAtomSet(crossFieldErrorsAtom);
30
+ const storedError = useAtomValue(errorAtom);
28
31
  const submitCount = useAtomValue(submitCountAtom);
29
32
  const validationAtom = React.useMemo(() => getOrCreateValidationAtom(fieldPath, fieldDef.schema), [fieldPath]);
30
33
  const validationResult = useAtomValue(validationAtom);
@@ -37,12 +40,12 @@ const makeFieldComponent = (fieldKey, fieldDef, crossFieldErrorsAtom, submitCoun
37
40
  return;
38
41
  }
39
42
  prevValueRef.current = value;
40
- const shouldValidate = parsedMode.validation === "onChange" || parsedMode.validation === "onBlur" && isTouched;
43
+ const shouldValidate = parsedMode.validation === "onChange" || parsedMode.validation === "onBlur" && isTouched || parsedMode.validation === "onSubmit" && submitCount > 0;
41
44
  if (shouldValidate) {
42
45
  validate(value);
43
46
  }
44
- }, [value, isTouched, validate]);
45
- const perFieldError = React.useMemo(() => {
47
+ }, [value, isTouched, submitCount, validate]);
48
+ const livePerFieldError = React.useMemo(() => {
46
49
  if (validationResult._tag === "Failure") {
47
50
  const parseError = Cause.failureOption(validationResult.cause);
48
51
  if (Option.isSome(parseError) && ParseResult.isParseError(parseError.value)) {
@@ -51,22 +54,25 @@ const makeFieldComponent = (fieldKey, fieldDef, crossFieldErrorsAtom, submitCoun
51
54
  }
52
55
  return Option.none();
53
56
  }, [validationResult]);
54
- const validationError = Option.isSome(perFieldError) ? perFieldError : crossFieldError;
55
- const onChange = React.useCallback(newValue => {
56
- setValue(newValue);
57
- setCrossFieldErrors(prev => {
58
- const next = new Map();
59
- for (const [errorPath, message] of prev) {
60
- if (!isPathUnderRoot(errorPath, fieldPath)) {
61
- next.set(errorPath, message);
62
- }
57
+ const isValidating = validationResult.waiting;
58
+ const validationError = React.useMemo(() => {
59
+ if (Option.isSome(livePerFieldError)) {
60
+ return livePerFieldError;
61
+ }
62
+ if (Option.isSome(storedError)) {
63
+ // Hide field-sourced errors when validation passes or is pending (async gap).
64
+ // Refinement errors persist until re-submit - they can't be cleared by typing.
65
+ const shouldHideStoredError = storedError.value.source === "field" && (validationResult._tag === "Success" || isValidating);
66
+ if (shouldHideStoredError) {
67
+ return Option.none();
63
68
  }
64
- return next.size !== prev.size ? next : prev;
65
- });
66
- if (parsedMode.validation === "onChange") {
67
- validate(newValue);
69
+ return Option.some(storedError.value.message);
68
70
  }
69
- }, [fieldPath, setValue, setCrossFieldErrors, validate]);
71
+ return Option.none();
72
+ }, [livePerFieldError, storedError, validationResult, isValidating]);
73
+ const onChange = React.useCallback(newValue => {
74
+ setValue(newValue);
75
+ }, [setValue]);
70
76
  const onBlur = React.useCallback(() => {
71
77
  setTouched(true);
72
78
  if (parsedMode.validation === "onBlur") {
@@ -76,8 +82,7 @@ const makeFieldComponent = (fieldKey, fieldDef, crossFieldErrorsAtom, submitCoun
76
82
  }, [setTouched, validate, value, autoSubmitOnBlur]);
77
83
  const dirtyFields = useAtomValue(dirtyFieldsAtom);
78
84
  const isDirty = React.useMemo(() => isPathOrParentDirty(dirtyFields, fieldPath), [dirtyFields, fieldPath]);
79
- const isValidating = validationResult.waiting;
80
- const shouldShowError = isTouched || submitCount > 0;
85
+ const shouldShowError = parsedMode.validation === "onChange" ? isDirty || submitCount > 0 : parsedMode.validation === "onBlur" ? isTouched || submitCount > 0 : submitCount > 0;
81
86
  const fieldState = React.useMemo(() => ({
82
87
  value,
83
88
  onChange,
@@ -94,7 +99,7 @@ const makeFieldComponent = (fieldKey, fieldDef, crossFieldErrorsAtom, submitCoun
94
99
  };
95
100
  return React.memo(FieldComponent);
96
101
  };
97
- const makeArrayFieldComponent = (fieldKey, def, stateAtom, crossFieldErrorsAtom, submitCountAtom, dirtyFieldsAtom, parsedMode, getOrCreateValidationAtom, getOrCreateFieldAtoms, operations, componentMap) => {
102
+ const makeArrayFieldComponent = (fieldKey, def, stateAtom, errorsAtom, submitCountAtom, dirtyFieldsAtom, parsedMode, getOrCreateValidationAtom, getOrCreateFieldAtoms, operations, componentMap) => {
98
103
  const isStructSchema = AST.isTypeLiteral(def.itemSchema.ast);
99
104
  const ArrayWrapper = ({
100
105
  children
@@ -172,14 +177,13 @@ const makeArrayFieldComponent = (fieldKey, def, stateAtom, crossFieldErrorsAtom,
172
177
  };
173
178
  const itemDef = Field.makeField(itemKey, itemSchema);
174
179
  const itemComponent = componentMap[itemKey];
175
- itemFieldComponents[itemKey] = makeFieldComponent(itemKey, itemDef, crossFieldErrorsAtom, submitCountAtom, dirtyFieldsAtom, parsedMode, getOrCreateValidationAtom, getOrCreateFieldAtoms, itemComponent);
180
+ itemFieldComponents[itemKey] = makeFieldComponent(itemKey, itemDef, errorsAtom, submitCountAtom, dirtyFieldsAtom, parsedMode, getOrCreateValidationAtom, getOrCreateFieldAtoms, itemComponent);
176
181
  }
177
182
  }
178
183
  const properties = {
179
184
  Item: ItemWrapper,
180
185
  ...itemFieldComponents
181
186
  };
182
- // Proxy enables <Form.items.Item> and <Form.items.name> syntax
183
187
  return new Proxy(ArrayWrapper, {
184
188
  get(target, prop) {
185
189
  if (prop in properties) {
@@ -189,48 +193,45 @@ const makeArrayFieldComponent = (fieldKey, def, stateAtom, crossFieldErrorsAtom,
189
193
  }
190
194
  });
191
195
  };
192
- const makeFieldComponents = (fields, stateAtom, crossFieldErrorsAtom, submitCountAtom, dirtyFieldsAtom, parsedMode, getOrCreateValidationAtom, getOrCreateFieldAtoms, operations, componentMap) => {
196
+ const makeFieldComponents = (fields, stateAtom, errorsAtom, submitCountAtom, dirtyFieldsAtom, parsedMode, getOrCreateValidationAtom, getOrCreateFieldAtoms, operations, componentMap) => {
193
197
  const components = {};
194
198
  for (const [key, def] of Object.entries(fields)) {
195
199
  if (Field.isArrayFieldDef(def)) {
196
200
  const arrayComponentMap = componentMap[key];
197
- components[key] = makeArrayFieldComponent(key, def, stateAtom, crossFieldErrorsAtom, submitCountAtom, dirtyFieldsAtom, parsedMode, getOrCreateValidationAtom, getOrCreateFieldAtoms, operations, arrayComponentMap);
201
+ components[key] = makeArrayFieldComponent(key, def, stateAtom, errorsAtom, submitCountAtom, dirtyFieldsAtom, parsedMode, getOrCreateValidationAtom, getOrCreateFieldAtoms, operations, arrayComponentMap);
198
202
  } else if (Field.isFieldDef(def)) {
199
- const fieldComponent = componentMap[key];
200
- components[key] = makeFieldComponent(key, def, crossFieldErrorsAtom, submitCountAtom, dirtyFieldsAtom, parsedMode, getOrCreateValidationAtom, getOrCreateFieldAtoms, fieldComponent);
203
+ const componentOrBundle = componentMap[key];
204
+ const fieldComponent = isFieldBundle(componentOrBundle) ? componentOrBundle.component : componentOrBundle;
205
+ components[key] = makeFieldComponent(key, def, errorsAtom, submitCountAtom, dirtyFieldsAtom, parsedMode, getOrCreateValidationAtom, getOrCreateFieldAtoms, fieldComponent);
201
206
  }
202
207
  }
203
208
  return components;
204
209
  };
205
210
  /**
206
- * Builds a React form from a FormBuilder.
211
+ * Creates a React form from a FormBuilder.
207
212
  *
208
213
  * @example
209
214
  * ```tsx
210
215
  * import { FormBuilder } from "@lucas-barake/effect-form"
211
216
  * import { FormReact } from "@lucas-barake/effect-form-react"
212
217
  * import { useAtomValue, useAtomSet } from "@effect-atom/atom-react"
213
- * import * as Atom from "@effect-atom/atom/Atom"
214
218
  * import * as Schema from "effect/Schema"
215
- * import * as Layer from "effect/Layer"
216
- *
217
- * const runtime = Atom.runtime(Layer.empty)
218
219
  *
219
- * const loginForm = FormBuilder.empty
220
+ * const loginFormBuilder = FormBuilder.empty
220
221
  * .addField("email", Schema.String)
221
222
  * .addField("password", Schema.String)
222
223
  *
223
- * const form = FormReact.build(loginForm, {
224
- * runtime,
224
+ * // Runtime is optional for forms without service requirements
225
+ * const loginForm = FormReact.make(loginFormBuilder, {
225
226
  * fields: { email: TextInput, password: PasswordInput },
226
- * onSubmit: (values) => Effect.log(`Login: ${values.email}`),
227
+ * onSubmit: (_, { decoded }) => Effect.log(`Login: ${decoded.email}`),
227
228
  * })
228
229
  *
229
230
  * // Subscribe to atoms anywhere in the tree
230
231
  * function SubmitButton() {
231
- * const isDirty = useAtomValue(form.isDirty)
232
- * const submit = useAtomValue(form.submit)
233
- * const callSubmit = useAtomSet(form.submit)
232
+ * const isDirty = useAtomValue(loginForm.isDirty)
233
+ * const submit = useAtomValue(loginForm.submit)
234
+ * const callSubmit = useAtomSet(loginForm.submit)
234
235
  * return (
235
236
  * <button onClick={() => callSubmit()} disabled={!isDirty || submit.waiting}>
236
237
  * {submit.waiting ? "Validating..." : "Login"}
@@ -238,26 +239,27 @@ const makeFieldComponents = (fields, stateAtom, crossFieldErrorsAtom, submitCoun
238
239
  * )
239
240
  * }
240
241
  *
241
- * function LoginDialog({ onClose }) {
242
+ * function LoginPage() {
242
243
  * return (
243
- * <form.Initialize defaultValues={{ email: "", password: "" }}>
244
- * <form.email />
245
- * <form.password />
244
+ * <loginForm.Initialize defaultValues={{ email: "", password: "" }}>
245
+ * <loginForm.email />
246
+ * <loginForm.password />
246
247
  * <SubmitButton />
247
- * </form.Initialize>
248
+ * </loginForm.Initialize>
248
249
  * )
249
250
  * }
250
251
  * ```
251
252
  *
252
253
  * @category Constructors
253
254
  */
254
- export const build = (self, options) => {
255
+ export const make = (self, options) => {
255
256
  const {
256
257
  fields: components,
257
258
  mode,
258
259
  onSubmit,
259
- runtime
260
+ runtime: providedRuntime
260
261
  } = options;
262
+ const runtime = providedRuntime ?? Atom.runtime(Layer.empty);
261
263
  const parsedMode = Mode.parse(mode);
262
264
  const {
263
265
  fields
@@ -269,18 +271,21 @@ export const build = (self, options) => {
269
271
  });
270
272
  const {
271
273
  combinedSchema,
272
- crossFieldErrorsAtom,
273
274
  dirtyFieldsAtom,
275
+ errorsAtom,
274
276
  fieldRefs,
275
277
  getFieldAtom,
276
278
  getOrCreateFieldAtoms,
277
279
  getOrCreateValidationAtom,
278
280
  hasChangedSinceSubmitAtom,
279
281
  isDirtyAtom,
282
+ keepAliveActiveAtom,
280
283
  lastSubmittedValuesAtom,
284
+ mountAtom,
281
285
  operations,
282
286
  resetAtom,
283
287
  revertToLastSubmitAtom,
288
+ rootErrorAtom,
284
289
  setValue,
285
290
  setValuesAtom,
286
291
  stateAtom,
@@ -298,49 +303,102 @@ export const build = (self, options) => {
298
303
  const callSubmit = useAtomSet(submitAtom);
299
304
  const isInitializedRef = React.useRef(false);
300
305
  React.useEffect(() => {
301
- setFormState(Option.some(operations.createInitialState(defaultValues)));
306
+ const isKeptAlive = registry.get(keepAliveActiveAtom);
307
+ const currentState = registry.get(stateAtom);
308
+ if (!isKeptAlive) {
309
+ setFormState(Option.some(operations.createInitialState(defaultValues)));
310
+ } else if (Option.isNone(currentState)) {
311
+ setFormState(Option.some(operations.createInitialState(defaultValues)));
312
+ }
302
313
  isInitializedRef.current = true;
303
314
  // eslint-disable-next-line react-hooks/exhaustive-deps -- mount-only
304
- }, []);
315
+ }, [registry]);
305
316
  const debouncedAutoSubmit = useDebounced(() => {
306
317
  const stateOption = registry.get(stateAtom);
307
318
  if (Option.isNone(stateOption)) return;
308
319
  callSubmit(undefined);
309
320
  }, parsedMode.autoSubmit && parsedMode.validation === "onChange" ? parsedMode.debounce : null);
321
+ // ─────────────────────────────────────────────────────────────────────────────
322
+ // Auto-Submit Coordination
323
+ // ─────────────────────────────────────────────────────────────────────────────
324
+ // Two-subscription model to avoid infinite loop:
325
+ // - Stream 1 reacts to value changes (reference equality), triggers or queues submit
326
+ // - Stream 2 reacts to submit completion, flushes queued changes
327
+ //
328
+ // Single subscription to stateAtom cannot distinguish value changes from submit
329
+ // metadata updates (submitCount, lastSubmittedValues).
330
+ // ─────────────────────────────────────────────────────────────────────────────
331
+ const lastValuesRef = React.useRef(null);
332
+ const pendingChangesRef = React.useRef(false);
333
+ const wasSubmittingRef = React.useRef(false);
310
334
  useAtomSubscribe(stateAtom, React.useCallback(() => {
311
335
  if (!isInitializedRef.current) return;
312
- if (parsedMode.autoSubmit && parsedMode.validation === "onChange") {
336
+ const state = registry.get(stateAtom);
337
+ if (Option.isNone(state)) return;
338
+ const currentValues = state.value.values;
339
+ // Reference equality filters out submit metadata changes.
340
+ // Works because setFieldValue creates new values object (immutable update).
341
+ if (currentValues === lastValuesRef.current) return;
342
+ lastValuesRef.current = currentValues;
343
+ if (!parsedMode.autoSubmit || parsedMode.validation !== "onChange") return;
344
+ const submitResult = registry.get(submitAtom);
345
+ if (submitResult.waiting) {
346
+ pendingChangesRef.current = true;
347
+ } else {
313
348
  debouncedAutoSubmit();
314
349
  }
350
+ }, [debouncedAutoSubmit, registry]), {
351
+ immediate: false
352
+ });
353
+ useAtomSubscribe(submitAtom, React.useCallback(result => {
354
+ if (!parsedMode.autoSubmit || parsedMode.validation !== "onChange") return;
355
+ const isSubmitting = result.waiting;
356
+ const wasSubmitting = wasSubmittingRef.current;
357
+ wasSubmittingRef.current = isSubmitting;
358
+ // Flush queued changes when submit completes
359
+ if (wasSubmitting && !isSubmitting) {
360
+ if (pendingChangesRef.current) {
361
+ pendingChangesRef.current = false;
362
+ debouncedAutoSubmit();
363
+ }
364
+ }
315
365
  }, [debouncedAutoSubmit]), {
316
366
  immediate: false
317
367
  });
318
368
  const onBlurAutoSubmit = React.useCallback(() => {
319
- if (parsedMode.autoSubmit && parsedMode.validation === "onBlur") {
320
- const stateOption = registry.get(stateAtom);
321
- if (Option.isNone(stateOption)) return;
322
- callSubmit(undefined);
323
- }
369
+ if (!parsedMode.autoSubmit || parsedMode.validation !== "onBlur") return;
370
+ const stateOption = registry.get(stateAtom);
371
+ if (Option.isNone(stateOption)) return;
372
+ const {
373
+ lastSubmittedValues,
374
+ values
375
+ } = stateOption.value;
376
+ if (Option.isSome(lastSubmittedValues) && values === lastSubmittedValues.value.encoded) return;
377
+ callSubmit(undefined);
324
378
  }, [registry, callSubmit]);
325
379
  if (Option.isNone(state)) return null;
326
380
  return _jsx(AutoSubmitContext.Provider, {
327
381
  value: onBlurAutoSubmit,
328
- children: _jsx("form", {
329
- onSubmit: e => {
330
- e.preventDefault();
331
- e.stopPropagation();
332
- },
333
- children: children
334
- })
382
+ children: children
335
383
  });
336
384
  };
337
- const fieldComponents = makeFieldComponents(fields, stateAtom, crossFieldErrorsAtom, submitCountAtom, dirtyFieldsAtom, parsedMode, getOrCreateValidationAtom, getOrCreateFieldAtoms, operations, components);
385
+ const fieldComponents = makeFieldComponents(fields, stateAtom, errorsAtom, submitCountAtom, dirtyFieldsAtom, parsedMode, getOrCreateValidationAtom, getOrCreateFieldAtoms, operations, components);
386
+ const KeepAlive = () => {
387
+ const setKeepAliveActive = useAtomSet(keepAliveActiveAtom);
388
+ React.useLayoutEffect(() => {
389
+ setKeepAliveActive(true);
390
+ return () => setKeepAliveActive(false);
391
+ }, [setKeepAliveActive]);
392
+ useAtomMount(mountAtom);
393
+ return null;
394
+ };
338
395
  return {
339
396
  values: valuesAtom,
340
397
  isDirty: isDirtyAtom,
341
398
  hasChangedSinceSubmit: hasChangedSinceSubmitAtom,
342
399
  lastSubmittedValues: lastSubmittedValuesAtom,
343
400
  submitCount: submitCountAtom,
401
+ rootError: rootErrorAtom,
344
402
  schema: combinedSchema,
345
403
  fields: fieldRefs,
346
404
  Initialize: InitializeComponent,
@@ -350,30 +408,26 @@ export const build = (self, options) => {
350
408
  setValues: setValuesAtom,
351
409
  setValue,
352
410
  getFieldAtom,
411
+ mount: mountAtom,
412
+ KeepAlive,
353
413
  ...fieldComponents
354
414
  };
355
415
  };
356
416
  /**
357
- * A curried helper that infers the schema type from a field definition or field reference.
417
+ * A curried helper that infers the schema type from a field definition.
358
418
  * Provides ergonomic type inference when defining field components.
359
419
  *
360
420
  * @example
361
421
  * ```tsx
362
- * import { FormReact } from "@lucas-barake/effect-form-react"
422
+ * import { Field, FormReact } from "@lucas-barake/effect-form-react"
363
423
  *
364
- * // Using a FieldRef from the built form
365
- * const TextInput = FormReact.forField(form.fields.email)(({ field }) => (
366
- * <input value={field.value} onChange={e => field.onChange(e.target.value)} />
367
- * ))
368
- *
369
- * // Using a FieldDef (for reusable fields)
370
424
  * const EmailField = Field.makeField("email", Schema.String)
371
425
  * const TextInput = FormReact.forField(EmailField)(({ field }) => (
372
426
  * <input value={field.value} onChange={e => field.onChange(e.target.value)} />
373
427
  * ))
374
428
  *
375
429
  * // With extra props - just specify the props type
376
- * const TextInput = FormReact.forField(form.fields.email)<{ placeholder?: string }>(({ field, props }) => (
430
+ * const TextInput = FormReact.forField(EmailField)<{ placeholder?: string }>(({ field, props }) => (
377
431
  * <input value={field.value} placeholder={props.placeholder} ... />
378
432
  * ))
379
433
  * ```
@@ -381,4 +435,72 @@ export const build = (self, options) => {
381
435
  * @category Constructors
382
436
  */
383
437
  export const forField = _field => component => component;
438
+ /**
439
+ * Creates a bundled field definition + component for reusable form fields.
440
+ * Reduces boilerplate when you need both a field and its component together.
441
+ *
442
+ * Uses a curried API for better type inference - the schema type is captured
443
+ * first, so you only need to specify the extra props type (if any).
444
+ *
445
+ * @example
446
+ * ```tsx
447
+ * import { FormReact } from "@lucas-barake/effect-form-react"
448
+ * import * as Schema from "effect/Schema"
449
+ *
450
+ * // Define field + component in one place (no extra props)
451
+ * const NameInput = FormReact.makeField({
452
+ * key: "name",
453
+ * schema: Schema.String.pipe(Schema.nonEmptyString()),
454
+ * })(({ field }) => (
455
+ * <input
456
+ * value={field.value}
457
+ * onChange={(e) => field.onChange(e.target.value)}
458
+ * onBlur={field.onBlur}
459
+ * />
460
+ * ))
461
+ *
462
+ * // With extra props - specify only the props type
463
+ * const EmailInput = FormReact.makeField({
464
+ * key: "email",
465
+ * schema: Schema.String,
466
+ * })<{ placeholder: string }>(({ field, props }) => (
467
+ * <input
468
+ * value={field.value}
469
+ * onChange={(e) => field.onChange(e.target.value)}
470
+ * placeholder={props.placeholder}
471
+ * />
472
+ * ))
473
+ *
474
+ * // Use in form builder
475
+ * const formBuilder = FormBuilder.empty.addField(NameInput.field)
476
+ *
477
+ * // Use in make()
478
+ * const form = FormReact.make(formBuilder, {
479
+ * runtime,
480
+ * fields: { name: NameInput },
481
+ * onSubmit: (_, { decoded }) => Effect.log(decoded.name),
482
+ * })
483
+ * ```
484
+ *
485
+ * @category Constructors
486
+ */
487
+ export const makeField = options => {
488
+ const field = Field.makeField(options.key, options.schema);
489
+ return component => {
490
+ if (!component.displayName) {
491
+ const displayName = `${options.key.charAt(0).toUpperCase()}${options.key.slice(1)}Field`;
492
+ try {
493
+ ;
494
+ component.displayName = displayName;
495
+ } catch {
496
+ // Ignore - some environments freeze function properties
497
+ }
498
+ }
499
+ return {
500
+ _tag: "FieldBundle",
501
+ field,
502
+ component
503
+ };
504
+ };
505
+ };
384
506
  //# sourceMappingURL=FormReact.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FormReact.js","names":["RegistryContext","useAtom","useAtomSet","useAtomSubscribe","useAtomValue","Field","FormAtoms","Mode","Validation","getNestedValue","isPathOrParentDirty","isPathUnderRoot","Cause","Option","ParseResult","AST","React","createContext","useContext","useDebounced","ArrayItemContext","AutoSubmitContext","makeFieldComponent","fieldKey","fieldDef","crossFieldErrorsAtom","submitCountAtom","dirtyFieldsAtom","parsedMode","getOrCreateValidationAtom","getOrCreateFieldAtoms","Component","FieldComponent","extraProps","arrayCtx","autoSubmitOnBlur","fieldPath","parentPath","crossFieldErrorAtom","touchedAtom","valueAtom","useMemo","value","setValue","isTouched","setTouched","crossFieldError","setCrossFieldErrors","submitCount","validationAtom","schema","validationResult","validateImmediate","shouldDebounceValidation","validation","debounce","autoSubmit","validate","prevValueRef","useRef","useEffect","current","shouldValidate","perFieldError","_tag","parseError","failureOption","cause","isSome","isParseError","extractFirstError","none","validationError","onChange","useCallback","newValue","prev","next","Map","errorPath","message","set","size","onBlur","dirtyFields","isDirty","isValidating","waiting","shouldShowError","fieldState","error","_jsx","field","props","memo","makeArrayFieldComponent","def","stateAtom","operations","componentMap","isStructSchema","isTypeLiteral","itemSchema","ast","ArrayWrapper","children","formStateOption","setFormState","formState","getOrThrow","items","values","append","isNone","some","appendArrayItem","remove","index","removeArrayItem","swap","indexA","indexB","swapArrayItems","move","from","to","moveArrayItem","_Fragment","ItemWrapper","itemPath","Provider","itemFieldComponents","prop","propertySignatures","itemKey","name","type","itemDef","makeField","itemComponent","properties","Item","Proxy","get","target","Reflect","makeFieldComponents","fields","components","key","Object","entries","isArrayFieldDef","arrayComponentMap","isFieldDef","fieldComponent","build","self","options","mode","onSubmit","runtime","parse","formAtoms","make","formBuilder","combinedSchema","fieldRefs","getFieldAtom","hasChangedSinceSubmitAtom","isDirtyAtom","lastSubmittedValuesAtom","resetAtom","revertToLastSubmitAtom","setValuesAtom","submitAtom","valuesAtom","InitializeComponent","defaultValues","registry","state","callSubmit","isInitializedRef","createInitialState","debouncedAutoSubmit","stateOption","undefined","immediate","onBlurAutoSubmit","e","preventDefault","stopPropagation","fieldComponents","hasChangedSinceSubmit","lastSubmittedValues","Initialize","submit","reset","revertToLastSubmit","setValues","forField","_field","component"],"sources":["../../src/FormReact.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,eAAe,EAAEC,OAAO,EAAEC,UAAU,EAAEC,gBAAgB,EAAEC,YAAY,QAAQ,yBAAyB;AAE9G,SAASC,KAAK,EAAEC,SAAS,EAAEC,IAAI,EAAEC,UAAU,QAAQ,2BAA2B;AAE9E,SAASC,cAAc,EAAEC,mBAAmB,EAAEC,eAAe,QAAQ,gCAAgC;AACrG,OAAO,KAAKC,KAAK,MAAM,cAAc;AAErC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,WAAW,MAAM,oBAAoB;AAEjD,OAAO,KAAKC,GAAG,MAAM,kBAAkB;AACvC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,aAAa,EAAEC,UAAU,QAAQ,OAAO;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ACK,SAAuB,CAAC;MACrC;IACF,CAAC,EAAE,CAACP,QAAQ,EAAEE,UAAU,CAAC,CAAC;IAE1B,IAAIxK,MAAM,CAACoG,MAAM,CAACmE,KAAK,CAAC,EAAE,OAAO,IAAI;IAErC,OACEzF,IAAA,CAACtE,iBAAiB,CAAC6G,QAAQ;MAACxF,KAAK,EAAEkJ,gBAAgB;MAAAnF,QAAA,EACjDd,IAAA;QACEqE,QAAQ,EAAG6B,CAAC,IAAI;UACdA,CAAC,CAACC,cAAc,EAAE;UAClBD,CAAC,CAACE,eAAe,EAAE;QACrB,CAAC;QAAAtF,QAAA,EAEAA;MAAQ;IACJ,EACoB;EAEjC,CAAC;EAED,MAAMuF,eAAe,GAAG9C,mBAAmB,CACzCC,MAAM,EACNlD,SAAS,EACTxE,oBAAoB,EACpBC,eAAe,EACfC,eAAe,EACfC,UAAU,EACVC,yBAAyB,EACzBC,qBAAqB,EACrBoE,UAAU,EACVkD,UAAU,CACX;EAED,OAAO;IACLrC,MAAM,EAAEiE,UAAU;IAClB3F,OAAO,EAAEqF,WAAW;IACpBuB,qBAAqB,EAAExB,yBAAyB;IAChDyB,mBAAmB,EAAEvB,uBAAuB;IAC5C3H,WAAW,EAAEtB,eAAe;IAC5BwB,MAAM,EAAEoH,cAAc;IACtBnB,MAAM,EAAEoB,SAAS;IACjB4B,UAAU,EAAElB,mBAAmB;IAC/BmB,MAAM,EAAErB,UAAU;IAClBsB,KAAK,EAAEzB,SAAS;IAChB0B,kBAAkB,EAAEzB,sBAAsB;IAC1C0B,SAAS,EAAEzB,aAAa;IACxBnI,QAAQ;IACR6H,YAAY;IACZ,GAAGwB;GAC2C;AAClD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,OAAO,MAAMQ,QAAQ,GAYhBC,MAAe,IAAMC,SAAkB,IAAKA,SAAgB","ignoreList":[]}
1
+ {"version":3,"file":"FormReact.js","names":["RegistryContext","useAtom","useAtomMount","useAtomSet","useAtomSubscribe","useAtomValue","Atom","Field","FormAtoms","Mode","Validation","getNestedValue","isPathOrParentDirty","Cause","Layer","Option","ParseResult","Predicate","AST","React","createContext","useContext","useDebounced","isFieldBundle","x","isTagged","ArrayItemContext","AutoSubmitContext","makeFieldComponent","fieldKey","fieldDef","errorsAtom","submitCountAtom","dirtyFieldsAtom","parsedMode","getOrCreateValidationAtom","getOrCreateFieldAtoms","Component","FieldComponent","extraProps","arrayCtx","autoSubmitOnBlur","fieldPath","parentPath","errorAtom","touchedAtom","valueAtom","useMemo","value","setValue","isTouched","setTouched","storedError","submitCount","validationAtom","schema","validationResult","validateImmediate","shouldDebounceValidation","validation","debounce","autoSubmit","validate","prevValueRef","useRef","useEffect","current","shouldValidate","livePerFieldError","_tag","parseError","failureOption","cause","isSome","isParseError","extractFirstError","none","isValidating","waiting","validationError","shouldHideStoredError","source","some","message","onChange","useCallback","newValue","onBlur","dirtyFields","isDirty","shouldShowError","fieldState","error","_jsx","field","props","memo","makeArrayFieldComponent","def","stateAtom","operations","componentMap","isStructSchema","isTypeLiteral","itemSchema","ast","ArrayWrapper","children","formStateOption","setFormState","formState","getOrThrow","items","values","append","prev","isNone","appendArrayItem","remove","index","removeArrayItem","swap","indexA","indexB","swapArrayItems","move","from","to","moveArrayItem","_Fragment","ItemWrapper","itemPath","Provider","itemFieldComponents","prop","propertySignatures","itemKey","name","type","itemDef","makeField","itemComponent","properties","Item","Proxy","get","target","Reflect","makeFieldComponents","fields","components","key","Object","entries","isArrayFieldDef","arrayComponentMap","isFieldDef","componentOrBundle","fieldComponent","component","make","self","options","mode","onSubmit","runtime","providedRuntime","empty","parse","formAtoms","formBuilder","combinedSchema","fieldRefs","getFieldAtom","hasChangedSinceSubmitAtom","isDirtyAtom","keepAliveActiveAtom","lastSubmittedValuesAtom","mountAtom","resetAtom","revertToLastSubmitAtom","rootErrorAtom","setValuesAtom","submitAtom","valuesAtom","InitializeComponent","defaultValues","registry","state","callSubmit","isInitializedRef","isKeptAlive","currentState","createInitialState","debouncedAutoSubmit","stateOption","undefined","lastValuesRef","pendingChangesRef","wasSubmittingRef","currentValues","submitResult","immediate","result","isSubmitting","wasSubmitting","onBlurAutoSubmit","lastSubmittedValues","encoded","fieldComponents","KeepAlive","setKeepAliveActive","useLayoutEffect","hasChangedSinceSubmit","rootError","Initialize","submit","reset","revertToLastSubmit","setValues","mount","forField","_field","displayName","charAt","toUpperCase","slice"],"sources":["../../src/FormReact.tsx"],"sourcesContent":[null],"mappings":";AAAA,SACEA,eAAe,EACfC,OAAO,EACPC,YAAY,EACZC,UAAU,EACVC,gBAAgB,EAChBC,YAAY,QACP,yBAAyB;AAChC,OAAO,KAAKC,IAAI,MAAM,wBAAwB;AAC9C,SAASC,KAAK,EAAEC,SAAS,EAAEC,IAAI,EAAEC,UAAU,QAAQ,2BAA2B;AAE9E,SAASC,cAAc,EAAEC,mBAAmB,QAAQ,gCAAgC;AACpF,OAAO,KAAKC,KAAK,MAAM,cAAc;AAErC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,WAAW,MAAM,oBAAoB;AACjD,OAAO,KAAKC,SAAS,MAAM,kBAAkB;AAE7C,OAAO,KAAKC,GAAG,MAAM,kBAAkB;AACvC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,aAAa,EAAEC,UAAU,QAAQ,OAAO;AACjD,SAASC,YAAY,QAAQ,6BAA6B;AA+C1D,MAAMC,aAAa,GAAIC,CAAU,IAC/BP,SAAS,CAACQ,QAAQ,CAACD,CAAC,EAAE,aAAa,CAAC;AAiItC,MAAME,gBAAgB,gBAAGN,aAAa,CAA+B,IAAI,CAAC;AAC1E,MAAMO,iBAAiB,gBAAGP,aAAa,CAAsB,IAAI,CAAC;AAElE,MAAMQ,kBAAkB,GAAGA,CACzBC,QAAgB,EAChBC,QAAmC,EACnCC,UAAiG,EACjGC,eAAkC,EAClCC,eAA+C,EAC/CC,UAA2B,EAC3BC,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ACX,GAAG,CAACyE,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,EAAE,GAAG/D,OAAO,CAACX,GAAG,CAAC2E,KAAK,CAAC,CAAC,CAAC,OAAO;MACxF,IAAI;QACF;QAAEnE,SAAiB,CAACgE,WAAW,GAAGA,WAAW;MAC/C,CAAC,CAAC,MAAM;QACN;MAAA;IAEJ;IACA,OAAO;MACL1J,IAAI,EAAE,aAAa;MACnByB,KAAK;MACLiE;KACD;EACH,CAAC;AACH,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucas-barake/effect-form-react",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "React bindings for @lucas-barake/effect-form",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -11,7 +11,7 @@
11
11
  "author": "Lucas Barake",
12
12
  "homepage": "https://github.com/lucas-barake/effect-form",
13
13
  "dependencies": {
14
- "@lucas-barake/effect-form": "^0.10.0"
14
+ "@lucas-barake/effect-form": "^0.12.0"
15
15
  },
16
16
  "peerDependencies": {
17
17
  "@effect-atom/atom": "^0.4.8",