@conform-to/dom 1.7.0 → 1.7.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/formdata.d.ts +5 -4
- package/dist/formdata.js +5 -12
- package/dist/formdata.mjs +5 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/vitest.config.d.ts +0 -3
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
╚══════╝ ╚═════╝ ╚═╝ ╚══╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
Version 1.7.
|
|
10
|
+
Version 1.7.1 / License MIT / Copyright (c) 2024 Edmund Hung
|
|
11
11
|
|
|
12
12
|
A type-safe form validation library utilizing web fundamentals to progressively enhance HTML Forms with full support for server frameworks like Remix and Next.js.
|
|
13
13
|
|
package/dist/formdata.d.ts
CHANGED
|
@@ -47,10 +47,10 @@ export declare function getValue(target: unknown, name: string): unknown;
|
|
|
47
47
|
* Check if the value is a plain object
|
|
48
48
|
*/
|
|
49
49
|
export declare function isPlainObject(obj: unknown): obj is Record<string | number | symbol, unknown>;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export declare function
|
|
50
|
+
type GlobalConstructors = {
|
|
51
|
+
[K in keyof typeof globalThis]: (typeof globalThis)[K] extends new (...args: any) => any ? K : never;
|
|
52
|
+
}[keyof typeof globalThis];
|
|
53
|
+
export declare function isGlobalInstance<ClassName extends GlobalConstructors>(obj: unknown, className: ClassName): obj is InstanceType<(typeof globalThis)[ClassName]>;
|
|
54
54
|
/**
|
|
55
55
|
* Normalize value by removing empty object or array, empty string and null values
|
|
56
56
|
*/
|
|
@@ -65,4 +65,5 @@ export declare function flatten(data: unknown, options?: {
|
|
|
65
65
|
prefix?: string;
|
|
66
66
|
}): Record<string, unknown>;
|
|
67
67
|
export declare function deepEqual<Value>(prev: Value, next: Value): boolean;
|
|
68
|
+
export {};
|
|
68
69
|
//# sourceMappingURL=formdata.d.ts.map
|
package/dist/formdata.js
CHANGED
|
@@ -141,16 +141,9 @@ function getValue(target, name) {
|
|
|
141
141
|
function isPlainObject(obj) {
|
|
142
142
|
return !!obj && obj.constructor === Object && Object.getPrototypeOf(obj) === Object.prototype;
|
|
143
143
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
*/
|
|
148
|
-
function isFile(obj) {
|
|
149
|
-
// Skip checking if File is not defined
|
|
150
|
-
if (typeof File === 'undefined') {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
return obj instanceof File;
|
|
144
|
+
function isGlobalInstance(obj, className) {
|
|
145
|
+
var Ctor = globalThis[className];
|
|
146
|
+
return typeof Ctor === 'function' && obj instanceof Ctor;
|
|
154
147
|
}
|
|
155
148
|
|
|
156
149
|
/**
|
|
@@ -178,7 +171,7 @@ function normalize(value) {
|
|
|
178
171
|
}
|
|
179
172
|
return value.map(item => normalize(item, acceptFile));
|
|
180
173
|
}
|
|
181
|
-
if (typeof value === 'string' && value === '' || value === null ||
|
|
174
|
+
if (typeof value === 'string' && value === '' || value === null || isGlobalInstance(value, 'File') && (!acceptFile || value.size === 0)) {
|
|
182
175
|
return;
|
|
183
176
|
}
|
|
184
177
|
return value;
|
|
@@ -257,7 +250,7 @@ exports.getChildPaths = getChildPaths;
|
|
|
257
250
|
exports.getFormData = getFormData;
|
|
258
251
|
exports.getPaths = getPaths;
|
|
259
252
|
exports.getValue = getValue;
|
|
260
|
-
exports.
|
|
253
|
+
exports.isGlobalInstance = isGlobalInstance;
|
|
261
254
|
exports.isPlainObject = isPlainObject;
|
|
262
255
|
exports.isPrefix = isPrefix;
|
|
263
256
|
exports.normalize = normalize;
|
package/dist/formdata.mjs
CHANGED
|
@@ -137,16 +137,9 @@ function getValue(target, name) {
|
|
|
137
137
|
function isPlainObject(obj) {
|
|
138
138
|
return !!obj && obj.constructor === Object && Object.getPrototypeOf(obj) === Object.prototype;
|
|
139
139
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
*/
|
|
144
|
-
function isFile(obj) {
|
|
145
|
-
// Skip checking if File is not defined
|
|
146
|
-
if (typeof File === 'undefined') {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
return obj instanceof File;
|
|
140
|
+
function isGlobalInstance(obj, className) {
|
|
141
|
+
var Ctor = globalThis[className];
|
|
142
|
+
return typeof Ctor === 'function' && obj instanceof Ctor;
|
|
150
143
|
}
|
|
151
144
|
|
|
152
145
|
/**
|
|
@@ -174,7 +167,7 @@ function normalize(value) {
|
|
|
174
167
|
}
|
|
175
168
|
return value.map(item => normalize(item, acceptFile));
|
|
176
169
|
}
|
|
177
|
-
if (typeof value === 'string' && value === '' || value === null ||
|
|
170
|
+
if (typeof value === 'string' && value === '' || value === null || isGlobalInstance(value, 'File') && (!acceptFile || value.size === 0)) {
|
|
178
171
|
return;
|
|
179
172
|
}
|
|
180
173
|
return value;
|
|
@@ -245,4 +238,4 @@ function deepEqual(prev, next) {
|
|
|
245
238
|
return false;
|
|
246
239
|
}
|
|
247
240
|
|
|
248
|
-
export { deepEqual, flatten, formatName, formatPaths, getChildPaths, getFormData, getPaths, getValue,
|
|
241
|
+
export { deepEqual, flatten, formatName, formatPaths, getChildPaths, getFormData, getPaths, getValue, isGlobalInstance, isPlainObject, isPrefix, normalize, setValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { type Combine, type Constraint, type ControlButtonProps, type FormId, type FieldName, type DefaultValue, type FormValue, type FormOptions, type FormState, type FormContext, type SubscriptionSubject, type SubscriptionScope, createFormContext as unstable_createFormContext, } from './form';
|
|
2
2
|
export { type FieldElement, isFieldElement, updateField as unstable_updateField, createFileList, createGlobalFormsObserver as unstable_createGlobalFormsObserver, focus as unstable_focus, change as unstable_change, blur as unstable_blur, } from './dom';
|
|
3
3
|
export { type Submission, type SubmissionResult, type Intent, INTENT, STATE, serializeIntent, parse, } from './submission';
|
|
4
|
-
export { getPaths, formatPaths, isPrefix, deepEqual as unstable_deepEqual, } from './formdata';
|
|
4
|
+
export { getPaths, formatPaths, isPrefix, isGlobalInstance, deepEqual as unstable_deepEqual, } from './formdata';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -23,5 +23,6 @@ exports.parse = submission.parse;
|
|
|
23
23
|
exports.serializeIntent = submission.serializeIntent;
|
|
24
24
|
exports.formatPaths = formdata.formatPaths;
|
|
25
25
|
exports.getPaths = formdata.getPaths;
|
|
26
|
+
exports.isGlobalInstance = formdata.isGlobalInstance;
|
|
26
27
|
exports.isPrefix = formdata.isPrefix;
|
|
27
28
|
exports.unstable_deepEqual = formdata.deepEqual;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { createFormContext as unstable_createFormContext } from './form.mjs';
|
|
2
2
|
export { createFileList, isFieldElement, blur as unstable_blur, change as unstable_change, createGlobalFormsObserver as unstable_createGlobalFormsObserver, focus as unstable_focus, updateField as unstable_updateField } from './dom.mjs';
|
|
3
3
|
export { INTENT, STATE, parse, serializeIntent } from './submission.mjs';
|
|
4
|
-
export { formatPaths, getPaths, isPrefix, deepEqual as unstable_deepEqual } from './formdata.mjs';
|
|
4
|
+
export { formatPaths, getPaths, isGlobalInstance, isPrefix, deepEqual as unstable_deepEqual } from './formdata.mjs';
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A set of opinionated helpers built on top of the Constraint Validation API",
|
|
4
4
|
"homepage": "https://conform.guide",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "1.7.
|
|
6
|
+
"version": "1.7.1",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"module": "./dist/index.mjs",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
package/dist/vitest.config.d.ts
DELETED