@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/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { type FieldProps, type FormState, type Schema, type Submission, parse, getFieldElements, } from '@conform-to/dom';
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, 'getFieldElements', {
11
+ Object.defineProperty(exports, 'createSubmission', {
12
12
  enumerable: true,
13
- get: function () { return dom.getFieldElements; }
13
+ get: function () { return dom.createSubmission; }
14
14
  });
15
- Object.defineProperty(exports, 'parse', {
15
+ Object.defineProperty(exports, 'createValidate', {
16
16
  enumerable: true,
17
- get: function () { return dom.parse; }
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(props) {
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: props.name,
10
- form: props.form,
11
- required: props.required,
12
- minLength: props.minLength,
13
- maxLength: props.maxLength,
14
- min: props.min,
15
- max: props.max,
16
- step: props.step,
17
- pattern: props.pattern,
18
- multiple: props.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 = props.defaultValue === attributes.value;
23
+ attributes.defaultChecked = config.defaultValue === attributes.value;
24
24
  } else {
25
- var _props$defaultValue;
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(props) {
33
- var _props$defaultValue2;
30
+ function select(config) {
31
+ var _config$defaultValue;
34
32
 
35
33
  return {
36
- name: props.name,
37
- form: props.form,
38
- defaultValue: props.multiple ? Array.isArray(props.defaultValue) ? props.defaultValue : [] : "".concat((_props$defaultValue2 = props.defaultValue) !== null && _props$defaultValue2 !== void 0 ? _props$defaultValue2 : ''),
39
- required: props.required,
40
- multiple: props.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(props) {
44
- var _props$defaultValue3;
41
+ function textarea(config) {
42
+ var _config$defaultValue2;
45
43
 
46
44
  return {
47
- name: props.name,
48
- form: props.form,
49
- defaultValue: "".concat((_props$defaultValue3 = props.defaultValue) !== null && _props$defaultValue3 !== void 0 ? _props$defaultValue3 : ''),
50
- required: props.required,
51
- minLength: props.minLength,
52
- maxLength: props.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