@conform-to/react 1.12.0 → 1.12.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/state.js +9 -1
- package/dist/future/state.mjs +9 -1
- package/dist/future/types.d.ts +6 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
╚══════╝ ╚═════╝ ╚═╝ ╚══╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
Version 1.12.
|
|
10
|
+
Version 1.12.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/state.js
CHANGED
|
@@ -328,15 +328,23 @@ function getField(context, options) {
|
|
|
328
328
|
if (typeof customize !== 'function') {
|
|
329
329
|
return metadata;
|
|
330
330
|
}
|
|
331
|
+
var customMetadata = null;
|
|
331
332
|
return new Proxy(metadata, {
|
|
332
333
|
get(target, prop, receiver) {
|
|
334
|
+
var _customMetadata;
|
|
333
335
|
if (Reflect.has(target, prop)) {
|
|
334
336
|
return Reflect.get(target, prop, receiver);
|
|
335
337
|
}
|
|
336
|
-
|
|
338
|
+
(_customMetadata = customMetadata) !== null && _customMetadata !== void 0 ? _customMetadata : customMetadata = customize(metadata);
|
|
337
339
|
if (Reflect.has(customMetadata, prop)) {
|
|
338
340
|
return Reflect.get(customMetadata, prop, receiver);
|
|
339
341
|
}
|
|
342
|
+
|
|
343
|
+
// Allow React DevTools to inspect the object
|
|
344
|
+
// without throwing errors for internal properties
|
|
345
|
+
if (typeof prop === 'symbol' || prop === '$$typeof') {
|
|
346
|
+
return undefined;
|
|
347
|
+
}
|
|
340
348
|
throw new Error("Property \"".concat(String(prop), "\" does not exist on field metadata. ") + "If you have defined the CustomMetadata interface to include \"".concat(String(prop), "\", make sure to also implement it through the \"defineCustomMetadata\" property on <FormOptionsProvider />."));
|
|
341
349
|
}
|
|
342
350
|
});
|
package/dist/future/state.mjs
CHANGED
|
@@ -324,15 +324,23 @@ function getField(context, options) {
|
|
|
324
324
|
if (typeof customize !== 'function') {
|
|
325
325
|
return metadata;
|
|
326
326
|
}
|
|
327
|
+
var customMetadata = null;
|
|
327
328
|
return new Proxy(metadata, {
|
|
328
329
|
get(target, prop, receiver) {
|
|
330
|
+
var _customMetadata;
|
|
329
331
|
if (Reflect.has(target, prop)) {
|
|
330
332
|
return Reflect.get(target, prop, receiver);
|
|
331
333
|
}
|
|
332
|
-
|
|
334
|
+
(_customMetadata = customMetadata) !== null && _customMetadata !== void 0 ? _customMetadata : customMetadata = customize(metadata);
|
|
333
335
|
if (Reflect.has(customMetadata, prop)) {
|
|
334
336
|
return Reflect.get(customMetadata, prop, receiver);
|
|
335
337
|
}
|
|
338
|
+
|
|
339
|
+
// Allow React DevTools to inspect the object
|
|
340
|
+
// without throwing errors for internal properties
|
|
341
|
+
if (typeof prop === 'symbol' || prop === '$$typeof') {
|
|
342
|
+
return undefined;
|
|
343
|
+
}
|
|
336
344
|
throw new Error("Property \"".concat(String(prop), "\" does not exist on field metadata. ") + "If you have defined the CustomMetadata interface to include \"".concat(String(prop), "\", make sure to also implement it through the \"defineCustomMetadata\" property on <FormOptionsProvider />."));
|
|
337
345
|
}
|
|
338
346
|
});
|
package/dist/future/types.d.ts
CHANGED
|
@@ -64,9 +64,9 @@ export type UseFormDataOptions = {
|
|
|
64
64
|
*/
|
|
65
65
|
acceptFiles?: boolean;
|
|
66
66
|
};
|
|
67
|
-
export type DefaultValue<FormShape> = FormShape extends
|
|
67
|
+
export type DefaultValue<FormShape> = FormShape extends Record<string, any> ? {
|
|
68
68
|
[Key in keyof FormShape]?: DefaultValue<FormShape[Key]>;
|
|
69
|
-
} | null | undefined : FormShape | string | null | undefined;
|
|
69
|
+
} | null | undefined : FormShape extends Array<infer Item> ? Array<DefaultValue<Item>> | null | undefined : FormShape | string | null | undefined;
|
|
70
70
|
export type FormState<ErrorShape extends BaseErrorShape = DefaultErrorShape> = {
|
|
71
71
|
/** Unique identifier that changes on form reset to trigger reset side effects */
|
|
72
72
|
resetKey: string;
|
|
@@ -117,7 +117,7 @@ export type GlobalFormOptions = {
|
|
|
117
117
|
*/
|
|
118
118
|
defineCustomMetadata?: CustomMetadataDefinition;
|
|
119
119
|
};
|
|
120
|
-
export type FormOptions<FormShape, ErrorShape extends BaseErrorShape = string extends BaseErrorShape ? string : BaseErrorShape, Value = undefined> = {
|
|
120
|
+
export type FormOptions<FormShape extends Record<string, any> = Record<string, any>, ErrorShape extends BaseErrorShape = string extends BaseErrorShape ? string : BaseErrorShape, Value = undefined> = {
|
|
121
121
|
/** Optional form identifier. If not provided, a unique ID is automatically generated. */
|
|
122
122
|
id?: string;
|
|
123
123
|
/** Optional key for form state reset. When the key changes, the form resets to its initial state. */
|
|
@@ -207,11 +207,11 @@ export interface IntentDispatcher {
|
|
|
207
207
|
/**
|
|
208
208
|
* Specify the index of the item to update if the field is an array.
|
|
209
209
|
*/
|
|
210
|
-
index?:
|
|
210
|
+
index?: FieldShape extends Array<any> ? number : never;
|
|
211
211
|
/**
|
|
212
212
|
* The new value for the field or fieldset.
|
|
213
213
|
*/
|
|
214
|
-
value:
|
|
214
|
+
value: DefaultValue<FieldShape>;
|
|
215
215
|
}): void;
|
|
216
216
|
/**
|
|
217
217
|
* Insert a new item into an array field.
|
|
@@ -229,9 +229,7 @@ export interface IntentDispatcher {
|
|
|
229
229
|
/**
|
|
230
230
|
* The default value for the new item.
|
|
231
231
|
*/
|
|
232
|
-
defaultValue?:
|
|
233
|
-
Array<infer ItemShape> | null | undefined
|
|
234
|
-
] ? Partial<ItemShape> : never;
|
|
232
|
+
defaultValue?: FieldShape extends Array<infer ItemShape> ? DefaultValue<ItemShape> : never;
|
|
235
233
|
}): void;
|
|
236
234
|
/**
|
|
237
235
|
* Remove an item from an array field.
|
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.12.
|
|
6
|
+
"version": "1.12.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.12.
|
|
44
|
+
"@conform-to/dom": "1.12.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@babel/core": "^7.17.8",
|