Skip to content

Commit 3b64110

Browse files
authored
chore: remove deprecated future APIs (#1285)
1 parent 92c5084 commit 3b64110

20 files changed

Lines changed: 75 additions & 368 deletions

File tree

.changeset/clean-future-exports.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@conform-to/dom': minor
3+
'@conform-to/react': minor
4+
'@conform-to/valibot': minor
5+
'@conform-to/zod': minor
6+
---
7+
8+
chore: remove deprecated Future APIs from the `/future` exports
9+
10+
- The `stripEmptyValues` option from `parseSubmission()`, deprecated in [v1.18.0](https://github.com/edmundhung/conform/releases/tag/v1.18.0), is now removed.
11+
- The `value` option from `report()`, deprecated in [v1.20.0](https://github.com/edmundhung/conform/releases/tag/v1.20.0), is now removed. Use `targetValue` instead.
12+
- The `invalid` property from field and form metadata, deprecated in [v1.9.1](https://github.com/edmundhung/conform/releases/tag/v1.9.1), is now removed. Use `!valid` instead.
13+
- The `getZodConstraint()` and `getValibotConstraint()` exports, deprecated in [v1.16.0](https://github.com/edmundhung/conform/releases/tag/v1.16.0), are now removed. Use `getConstraints()` instead.

docs/api/react/future/report.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ Set to `null` to indicate validation passed with no errors. If you need schema i
2929

3030
The target form value to apply. Use this to update the form or reset it to a specific value when combined with `reset: true`. Pass `null` to apply an empty value.
3131

32-
### `options.value?: Record<string, unknown> | null` (deprecated)
33-
34-
Deprecated alias for `targetValue`. It will be removed in the next minor release. When both options are provided, `targetValue` takes precedence.
35-
3632
### `options.keepFiles?: boolean`
3733

3834
Controls whether file objects are preserved in the submission payload:

docs/api/react/future/useField.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ Whether this field has been touched (through `intent.validate()` or the `shouldV
7676

7777
Whether this field currently has no validation errors.
7878

79-
### `invalid: boolean`
80-
81-
> **⚠️ Deprecated:** Use `valid` instead. This property will be removed in version 1.11.0.
82-
83-
Whether this field currently has validation errors. This is equivalent to `!valid`.
84-
8579
### `errors: ErrorShape | undefined`
8680

8781
Validation error for this field.

docs/api/react/future/useFormMetadata.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ Whether any field in the form has been touched (through `intent.validate()` or t
4848

4949
Whether the form currently has no validation errors.
5050

51-
### `invalid: boolean`
52-
53-
> **⚠️ Deprecated:** Use `valid` instead. This property will be removed in version 1.11.0.
54-
55-
Whether the form currently has any validation errors. This is equivalent to `!valid`.
56-
5751
### `errors: ErrorShape | undefined`
5852

5953
Form-level validation error, if any exists.

examples/headless-ui/src/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export default function App() {
241241
// name={fields.project.name}
242242
// defaultValue={fields.project.defaultValue}
243243
// required={fields.project.required}
244-
// invalid={fields.project.invalid}
244+
// invalid={!fields.project.valid}
245245
className="mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 shadow-sm data-focus:border-indigo-500 data-focus:ring-1 data-focus:ring-indigo-500 data-focus:outline-none sm:text-sm"
246246
/>
247247
<Description
@@ -266,7 +266,7 @@ export default function App() {
266266
// name={fields.notes.name}
267267
// defaultValue={fields.notes.defaultValue}
268268
// required={fields.notes.required}
269-
// invalid={fields.notes.invalid}
269+
// invalid={!fields.notes.valid}
270270
rows={3}
271271
className="mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 shadow-sm data-focus:border-indigo-500 data-focus:ring-1 data-focus:ring-indigo-500 data-focus:outline-none sm:text-sm"
272272
/>
@@ -292,7 +292,7 @@ export default function App() {
292292
// name={fields.priority.name}
293293
// defaultValue={fields.priority.defaultValue}
294294
// required={fields.priority.required}
295-
// invalid={fields.priority.invalid}
295+
// invalid={!fields.priority.valid}
296296
className="mt-1 block w-full rounded-md border border-gray-300 bg-white px-3 py-2 shadow-sm data-focus:border-indigo-500 data-focus:ring-1 data-focus:ring-indigo-500 data-focus:outline-none sm:text-sm"
297297
>
298298
<option value="low">Low</option>

examples/headless-ui/src/forms.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const forms = configureForms({
2121
name: metadata.name,
2222
defaultValue: metadata.defaultValue,
2323
required: metadata.required,
24-
invalid: metadata.invalid,
24+
invalid: !metadata.valid,
2525
} satisfies Partial<InputProps>;
2626
},
2727
get textareaProps() {
@@ -30,7 +30,7 @@ const forms = configureForms({
3030
name: metadata.name,
3131
defaultValue: metadata.defaultValue,
3232
required: metadata.required,
33-
invalid: metadata.invalid,
33+
invalid: !metadata.valid,
3434
} satisfies Partial<TextareaProps>;
3535
},
3636
get selectProps() {
@@ -39,7 +39,7 @@ const forms = configureForms({
3939
name: metadata.name,
4040
defaultValue: metadata.defaultValue,
4141
required: metadata.required,
42-
invalid: metadata.invalid,
42+
invalid: !metadata.valid,
4343
} satisfies Partial<SelectProps>;
4444
},
4545
get listBoxProps() {

packages/conform-dom/formdata.ts

Lines changed: 5 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -365,33 +365,6 @@ export function getPathValue(
365365
return pointer;
366366
}
367367

368-
/**
369-
* Check if a form value is considered empty and should be stripped from the submission.
370-
* A value is empty if:
371-
* - It's an empty string ""
372-
* - It's an empty File (size 0 and name "")
373-
* - It's an array where all items are empty
374-
*/
375-
function isEmptyValue(
376-
value: FormDataEntryValue | FormDataEntryValue[] | undefined,
377-
): boolean {
378-
if (value === '' || value === undefined) {
379-
return true;
380-
}
381-
382-
if (isGlobalInstance(value, 'File')) {
383-
// Empty File has size 0 and empty name
384-
return value.size === 0 && value.name === '';
385-
}
386-
387-
if (Array.isArray(value)) {
388-
// If all items are empty, consider it empty
389-
return value.every((item) => isEmptyValue(item));
390-
}
391-
392-
return false;
393-
}
394-
395368
/**
396369
* Parse `FormData` or `URLSearchParams` into a submission object.
397370
* This function structures the form values based on the naming convention.
@@ -436,15 +409,6 @@ export function parseSubmission(
436409
* Return `true` to skip the entry.
437410
*/
438411
skipEntry?: ((name: string) => boolean) | undefined;
439-
/**
440-
* Whether to strip empty values (empty strings, empty files, arrays with all empty values)
441-
* from the submission payload. Defaults to `false`.
442-
*
443-
* @deprecated This option will be removed in a future minor release.
444-
* If you are using a schema library like Zod or Valibot, our integration
445-
* already strips empty values for you. There is no need to use this option.
446-
*/
447-
stripEmptyValues?: boolean | undefined;
448412
},
449413
): Submission {
450414
const intentName = options?.intentName ?? DEFAULT_INTENT_NAME;
@@ -455,7 +419,6 @@ export function parseSubmission(
455419
};
456420

457421
const segmentsByName = new Map<string, Array<string | number> | null>();
458-
const stripEmptyValues = options?.stripEmptyValues ?? false;
459422
let intentValue: string | null | undefined = undefined;
460423

461424
for (const [name, entryValue] of formData) {
@@ -499,10 +462,6 @@ export function parseSubmission(
499462
submission.payload,
500463
segments,
501464
(current: unknown) => {
502-
if (stripEmptyValues && isEmptyValue(entryValue)) {
503-
return current;
504-
}
505-
506465
if (Array.isArray(current)) {
507466
current.push(entryValue);
508467
return current;
@@ -566,8 +525,6 @@ export function report(
566525
keepFiles?: false;
567526
error?: null;
568527
targetValue?: Record<string, FormValue> | null;
569-
/** @deprecated Use `targetValue` instead. This will be removed in the next minor release. */
570-
value?: Record<string, FormValue> | null;
571528
hideFields?: string[];
572529
reset?: boolean;
573530
},
@@ -578,8 +535,6 @@ export function report(
578535
keepFiles: true;
579536
error?: null;
580537
targetValue?: Record<string, FormValue> | null;
581-
/** @deprecated Use `targetValue` instead. This will be removed in the next minor release. */
582-
value?: Record<string, FormValue> | null;
583538
hideFields?: string[];
584539
reset?: boolean;
585540
},
@@ -590,8 +545,6 @@ export function report<ErrorShape>(
590545
keepFiles?: false;
591546
error: CustomError<ErrorShape> | null;
592547
targetValue?: Record<string, FormValue> | null;
593-
/** @deprecated Use `targetValue` instead. This will be removed in the next minor release. */
594-
value?: Record<string, FormValue> | null;
595548
hideFields?: string[];
596549
reset?: boolean;
597550
},
@@ -605,8 +558,6 @@ export function report<ErrorShape>(
605558
keepFiles: true;
606559
error: CustomError<ErrorShape> | null;
607560
targetValue?: Record<string, FormValue> | null;
608-
/** @deprecated Use `targetValue` instead. This will be removed in the next minor release. */
609-
value?: Record<string, FormValue> | null;
610561
hideFields?: string[];
611562
reset?: boolean;
612563
},
@@ -617,8 +568,6 @@ export function report(
617568
keepFiles?: false;
618569
error: StandardSchemaError;
619570
targetValue?: Record<string, FormValue> | null;
620-
/** @deprecated Use `targetValue` instead. This will be removed in the next minor release. */
621-
value?: Record<string, FormValue> | null;
622571
hideFields?: string[];
623572
reset?: boolean;
624573
},
@@ -632,8 +581,6 @@ export function report(
632581
keepFiles: true;
633582
error: StandardSchemaError;
634583
targetValue?: Record<string, FormValue> | null;
635-
/** @deprecated Use `targetValue` instead. This will be removed in the next minor release. */
636-
value?: Record<string, FormValue> | null;
637584
hideFields?: string[];
638585
reset?: boolean;
639586
},
@@ -644,8 +591,6 @@ export function report<ErrorShape>(
644591
keepFiles?: boolean;
645592
error?: CustomError<ErrorShape> | null;
646593
targetValue?: Record<string, FormValue> | null;
647-
/** @deprecated Use `targetValue` instead. This will be removed in the next minor release. */
648-
value?: Record<string, FormValue> | null;
649594
hideFields?: string[];
650595
reset?: boolean;
651596
},
@@ -668,10 +613,6 @@ export function report<ErrorShape>(
668613
* to a specific value when combined with `reset: true`.
669614
*/
670615
targetValue?: Record<string, FormValue> | null;
671-
/**
672-
* @deprecated Use `targetValue` instead. This will be removed in the next minor release.
673-
*/
674-
value?: Record<string, FormValue> | null;
675616
/**
676617
* Array of field names to hide from the result by setting them to `undefined`.
677618
* Primarily used for sensitive data like passwords that should not be sent back to the client.
@@ -693,15 +634,13 @@ export function report<ErrorShape>(
693634
error = normalizeFormError(options.error);
694635
}
695636

696-
const targetValueOption =
697-
'targetValue' in options ? options.targetValue : options.value;
698637
const targetValue =
699-
typeof targetValueOption === 'undefined' ||
700-
(submission.payload === targetValueOption && !options.reset)
638+
typeof options.targetValue === 'undefined' ||
639+
(submission.payload === options.targetValue && !options.reset)
701640
? undefined
702-
: targetValueOption && !options.keepFiles
703-
? stripFiles(targetValueOption)
704-
: (targetValueOption ?? {});
641+
: options.targetValue && !options.keepFiles
642+
? stripFiles(options.targetValue)
643+
: (options.targetValue ?? {});
705644

706645
if (options.hideFields) {
707646
for (const name of options.hideFields) {

0 commit comments

Comments
 (0)