@conform-to/react 1.10.0 → 1.10.1
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/README.md +1 -1
- package/dist/future/hooks.d.ts +1 -0
- package/dist/future/hooks.js +3 -1
- package/dist/future/hooks.mjs +3 -2
- package/dist/future/state.d.ts +1 -1
- package/dist/future/state.js +2 -2
- package/dist/future/state.mjs +2 -2
- package/dist/future/types.d.ts +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
╚══════╝ ╚═════╝ ╚═╝ ╚══╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
Version 1.10.
|
|
10
|
+
Version 1.10.1 / License MIT / Copyright (c) 2025 Edmund Hung
|
|
11
11
|
|
|
12
12
|
Progressively enhance HTML forms with React. Build resilient, type-safe forms with no hassle using web standards.
|
|
13
13
|
|
package/dist/future/hooks.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Serialize, type SubmissionResult, serialize } from '@conform-to/dom/future';
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
3
|
import type { FormContext, DefaultMetadata, IntentDispatcher, FormMetadata, Fieldset, FormOptions, FieldName, FieldMetadata, Control, Selector, UseFormDataOptions, ValidateHandler, ErrorHandler, SubmitHandler, FormState, FormRef } from './types';
|
|
4
|
+
export declare const INITIAL_KEY = "INITIAL_KEY";
|
|
4
5
|
export declare const FormConfig: import("react").Context<{
|
|
5
6
|
intentName: string;
|
|
6
7
|
observer: {
|
package/dist/future/hooks.js
CHANGED
|
@@ -12,6 +12,7 @@ var intent = require('./intent.js');
|
|
|
12
12
|
var dom = require('./dom.js');
|
|
13
13
|
var jsxRuntime = require('react/jsx-runtime');
|
|
14
14
|
|
|
15
|
+
var INITIAL_KEY = 'INITIAL_KEY';
|
|
15
16
|
var FormConfig = /*#__PURE__*/react.createContext({
|
|
16
17
|
intentName: future.DEFAULT_INTENT_NAME,
|
|
17
18
|
observer: future.createGlobalFormsObserver(),
|
|
@@ -51,7 +52,7 @@ function useConform(formRef, options) {
|
|
|
51
52
|
lastResult
|
|
52
53
|
} = options;
|
|
53
54
|
var [state$1, setState] = react.useState(() => {
|
|
54
|
-
var state$1 = state.initializeState();
|
|
55
|
+
var state$1 = state.initializeState(INITIAL_KEY);
|
|
55
56
|
if (lastResult) {
|
|
56
57
|
state$1 = state.updateState(state$1, _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, lastResult), {}, {
|
|
57
58
|
type: 'initialize',
|
|
@@ -746,6 +747,7 @@ function useLatest(value) {
|
|
|
746
747
|
exports.Form = Form;
|
|
747
748
|
exports.FormConfig = FormConfig;
|
|
748
749
|
exports.FormProvider = FormProvider;
|
|
750
|
+
exports.INITIAL_KEY = INITIAL_KEY;
|
|
749
751
|
exports.useConform = useConform;
|
|
750
752
|
exports.useControl = useControl;
|
|
751
753
|
exports.useField = useField;
|
package/dist/future/hooks.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { deserializeIntent, actionHandlers, applyIntent } from './intent.mjs';
|
|
|
8
8
|
import { focusFirstInvalidField, getFormElement, createIntentDispatcher, createDefaultSnapshot, getRadioGroupValue, getCheckboxGroupValue, getInputSnapshot, makeInputFocusable, initializeField, updateFormValue, getSubmitEvent } from './dom.mjs';
|
|
9
9
|
import { jsx } from 'react/jsx-runtime';
|
|
10
10
|
|
|
11
|
+
var INITIAL_KEY = 'INITIAL_KEY';
|
|
11
12
|
var FormConfig = /*#__PURE__*/createContext({
|
|
12
13
|
intentName: DEFAULT_INTENT_NAME,
|
|
13
14
|
observer: createGlobalFormsObserver(),
|
|
@@ -47,7 +48,7 @@ function useConform(formRef, options) {
|
|
|
47
48
|
lastResult
|
|
48
49
|
} = options;
|
|
49
50
|
var [state, setState] = useState(() => {
|
|
50
|
-
var state = initializeState();
|
|
51
|
+
var state = initializeState(INITIAL_KEY);
|
|
51
52
|
if (lastResult) {
|
|
52
53
|
state = updateState(state, _objectSpread2(_objectSpread2({}, lastResult), {}, {
|
|
53
54
|
type: 'initialize',
|
|
@@ -739,4 +740,4 @@ function useLatest(value) {
|
|
|
739
740
|
return ref;
|
|
740
741
|
}
|
|
741
742
|
|
|
742
|
-
export { Form, FormConfig, FormProvider, useConform, useControl, useField, useForm, useFormContext, useFormData, useFormMetadata, useIntent, useLatest, useSafeLayoutEffect };
|
|
743
|
+
export { Form, FormConfig, FormProvider, INITIAL_KEY, useConform, useControl, useField, useForm, useFormContext, useFormData, useFormMetadata, useIntent, useLatest, useSafeLayoutEffect };
|
package/dist/future/state.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ValidationAttributes, type Serialize } from '@conform-to/dom/future';
|
|
2
2
|
import type { DefaultMetadata, FieldMetadata, FieldName, Fieldset, FormContext, FormMetadata, FormState, FormAction, UnknownIntent, ActionHandler } from './types';
|
|
3
|
-
export declare function initializeState<ErrorShape>(): FormState<ErrorShape>;
|
|
3
|
+
export declare function initializeState<ErrorShape>(resetKey?: string): FormState<ErrorShape>;
|
|
4
4
|
/**
|
|
5
5
|
* Updates form state based on action type:
|
|
6
6
|
* - Client actions: update intended value and client errors
|
package/dist/future/state.js
CHANGED
|
@@ -6,9 +6,9 @@ var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.j
|
|
|
6
6
|
var future = require('@conform-to/dom/future');
|
|
7
7
|
var util = require('./util.js');
|
|
8
8
|
|
|
9
|
-
function initializeState() {
|
|
9
|
+
function initializeState(resetKey) {
|
|
10
10
|
return {
|
|
11
|
-
resetKey: util.generateUniqueKey(),
|
|
11
|
+
resetKey: resetKey !== null && resetKey !== void 0 ? resetKey : util.generateUniqueKey(),
|
|
12
12
|
listKeys: {},
|
|
13
13
|
clientIntendedValue: null,
|
|
14
14
|
serverIntendedValue: null,
|
package/dist/future/state.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import { objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelH
|
|
|
2
2
|
import { getPathSegments, getRelativePath, appendPathSegment, deepEqual, getValueAtPath, formatPathSegments, serialize } from '@conform-to/dom/future';
|
|
3
3
|
import { generateUniqueKey, merge, getArrayAtPath } from './util.mjs';
|
|
4
4
|
|
|
5
|
-
function initializeState() {
|
|
5
|
+
function initializeState(resetKey) {
|
|
6
6
|
return {
|
|
7
|
-
resetKey: generateUniqueKey(),
|
|
7
|
+
resetKey: resetKey !== null && resetKey !== void 0 ? resetKey : generateUniqueKey(),
|
|
8
8
|
listKeys: {},
|
|
9
9
|
clientIntendedValue: null,
|
|
10
10
|
serverIntendedValue: null,
|
package/dist/future/types.d.ts
CHANGED
|
@@ -274,7 +274,7 @@ export type FormMetadata<ErrorShape, Metadata extends Record<string, unknown> =
|
|
|
274
274
|
touched: boolean;
|
|
275
275
|
/** Whether the form currently has no validation errors. */
|
|
276
276
|
valid: boolean;
|
|
277
|
-
/** @deprecated Use `.valid` instead. This was not an
|
|
277
|
+
/** @deprecated Use `.valid` instead. This was not an intentional breaking change and would be removed in the next minor version soon */
|
|
278
278
|
invalid: boolean;
|
|
279
279
|
/** Form-level validation errors, if any exist. */
|
|
280
280
|
errors: ErrorShape[] | undefined;
|
|
@@ -293,7 +293,7 @@ export type FormMetadata<ErrorShape, Metadata extends Record<string, unknown> =
|
|
|
293
293
|
/** Method to get metadata for a specific field by name. */
|
|
294
294
|
getField<FieldShape>(name: FieldName<FieldShape>): FieldMetadata<FieldShape, Metadata>;
|
|
295
295
|
/** Method to get a fieldset object for nested object fields. */
|
|
296
|
-
getFieldset<FieldShape>(name
|
|
296
|
+
getFieldset<FieldShape>(name?: FieldName<FieldShape>): Fieldset<[
|
|
297
297
|
FieldShape
|
|
298
298
|
] extends [Record<string, unknown> | null | undefined] ? FieldShape : unknown, Metadata>;
|
|
299
299
|
/** Method to get an array of field objects for array fields. */
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Conform view adapter for react",
|
|
4
4
|
"homepage": "https://conform.guide",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "1.10.
|
|
6
|
+
"version": "1.10.1",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"module": "./dist/index.mjs",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"url": "https://github.com/edmundhung/conform/issues"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@conform-to/dom": "1.10.
|
|
44
|
+
"@conform-to/dom": "1.10.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@babel/core": "^7.17.8",
|