@conform-to/react 0.2.0 → 0.3.0-pre.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.
- package/README.md +319 -228
- package/helpers.d.ts +4 -4
- package/helpers.js +28 -30
- package/hooks.d.ts +114 -35
- package/hooks.js +394 -318
- package/index.d.ts +1 -1
- package/index.js +4 -4
- package/module/helpers.js +28 -30
- package/module/hooks.js +396 -320
- package/module/index.js +1 -1
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { type
|
|
1
|
+
export { type FormState, type FieldsetConstraint, type Schema, type Submission, createSubmission, createValidate, } from '@conform-to/dom';
|
|
2
2
|
export * from './hooks';
|
|
3
3
|
export * as conform from './helpers';
|
package/index.js
CHANGED
|
@@ -8,13 +8,13 @@ var helpers = require('./helpers.js');
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
Object.defineProperty(exports, '
|
|
11
|
+
Object.defineProperty(exports, 'createSubmission', {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return dom.
|
|
13
|
+
get: function () { return dom.createSubmission; }
|
|
14
14
|
});
|
|
15
|
-
Object.defineProperty(exports, '
|
|
15
|
+
Object.defineProperty(exports, 'createValidate', {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return dom.
|
|
17
|
+
get: function () { return dom.createValidate; }
|
|
18
18
|
});
|
|
19
19
|
exports.useControlledInput = hooks.useControlledInput;
|
|
20
20
|
exports.useFieldList = hooks.useFieldList;
|
package/module/helpers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function input(
|
|
1
|
+
function input(config) {
|
|
2
2
|
var {
|
|
3
3
|
type,
|
|
4
4
|
value
|
|
@@ -6,50 +6,48 @@ function input(props) {
|
|
|
6
6
|
var isCheckboxOrRadio = type === 'checkbox' || type === 'radio';
|
|
7
7
|
var attributes = {
|
|
8
8
|
type,
|
|
9
|
-
name:
|
|
10
|
-
form:
|
|
11
|
-
required:
|
|
12
|
-
minLength:
|
|
13
|
-
maxLength:
|
|
14
|
-
min:
|
|
15
|
-
max:
|
|
16
|
-
step:
|
|
17
|
-
pattern:
|
|
18
|
-
multiple:
|
|
9
|
+
name: config.name,
|
|
10
|
+
form: config.form,
|
|
11
|
+
required: config.required,
|
|
12
|
+
minLength: config.minLength,
|
|
13
|
+
maxLength: config.maxLength,
|
|
14
|
+
min: config.min,
|
|
15
|
+
max: config.max,
|
|
16
|
+
step: config.step,
|
|
17
|
+
pattern: config.pattern,
|
|
18
|
+
multiple: config.multiple
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
if (isCheckboxOrRadio) {
|
|
22
22
|
attributes.value = value !== null && value !== void 0 ? value : 'on';
|
|
23
|
-
attributes.defaultChecked =
|
|
23
|
+
attributes.defaultChecked = config.defaultValue === attributes.value;
|
|
24
24
|
} else {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
attributes.defaultValue = "".concat((_props$defaultValue = props.defaultValue) !== null && _props$defaultValue !== void 0 ? _props$defaultValue : '');
|
|
25
|
+
attributes.defaultValue = config.defaultValue;
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
return attributes;
|
|
31
29
|
}
|
|
32
|
-
function select(
|
|
33
|
-
var
|
|
30
|
+
function select(config) {
|
|
31
|
+
var _config$defaultValue;
|
|
34
32
|
|
|
35
33
|
return {
|
|
36
|
-
name:
|
|
37
|
-
form:
|
|
38
|
-
defaultValue:
|
|
39
|
-
required:
|
|
40
|
-
multiple:
|
|
34
|
+
name: config.name,
|
|
35
|
+
form: config.form,
|
|
36
|
+
defaultValue: config.multiple ? Array.isArray(config.defaultValue) ? config.defaultValue : [] : "".concat((_config$defaultValue = config.defaultValue) !== null && _config$defaultValue !== void 0 ? _config$defaultValue : ''),
|
|
37
|
+
required: config.required,
|
|
38
|
+
multiple: config.multiple
|
|
41
39
|
};
|
|
42
40
|
}
|
|
43
|
-
function textarea(
|
|
44
|
-
var
|
|
41
|
+
function textarea(config) {
|
|
42
|
+
var _config$defaultValue2;
|
|
45
43
|
|
|
46
44
|
return {
|
|
47
|
-
name:
|
|
48
|
-
form:
|
|
49
|
-
defaultValue: "".concat((
|
|
50
|
-
required:
|
|
51
|
-
minLength:
|
|
52
|
-
maxLength:
|
|
45
|
+
name: config.name,
|
|
46
|
+
form: config.form,
|
|
47
|
+
defaultValue: "".concat((_config$defaultValue2 = config.defaultValue) !== null && _config$defaultValue2 !== void 0 ? _config$defaultValue2 : ''),
|
|
48
|
+
required: config.required,
|
|
49
|
+
minLength: config.minLength,
|
|
50
|
+
maxLength: config.maxLength
|
|
53
51
|
};
|
|
54
52
|
}
|
|
55
53
|
|