@conform-to/react 1.18.0 → 1.19.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/dom.js +6 -2
- package/dist/future/dom.mjs +6 -2
- package/dist/future/forms.d.ts +1157 -26
- package/dist/future/forms.js +152 -23
- package/dist/future/forms.mjs +150 -26
- package/dist/future/hooks.d.ts +25 -164
- package/dist/future/hooks.js +49 -372
- package/dist/future/hooks.mjs +54 -369
- package/dist/future/index.d.ts +3 -3
- package/dist/future/index.js +5 -6
- package/dist/future/index.mjs +2 -2
- package/dist/future/intent.js +24 -12
- package/dist/future/intent.mjs +24 -12
- package/dist/future/memoize.d.ts +1 -1
- package/dist/future/memoize.js +1 -1
- package/dist/future/memoize.mjs +1 -1
- package/dist/future/state.d.ts +8 -12
- package/dist/future/state.js +24 -27
- package/dist/future/state.mjs +25 -28
- package/dist/future/types.d.ts +66 -111
- package/dist/future/util.d.ts +6 -10
- package/dist/future/util.js +17 -20
- package/dist/future/util.mjs +16 -19
- package/dist/helpers.d.ts +14 -10
- package/dist/helpers.js +14 -10
- package/dist/helpers.mjs +14 -10
- package/dist/integrations.js +8 -10
- package/dist/integrations.mjs +8 -10
- package/package.json +2 -2
package/dist/helpers.d.ts
CHANGED
|
@@ -85,7 +85,7 @@ export declare function getAriaAttributes(metadata: Metadata<any, any, any>, opt
|
|
|
85
85
|
* Derives the properties of a form element based on the form metadata,
|
|
86
86
|
* including `id`, `onSubmit`, `noValidate`, and `aria-describedby`.
|
|
87
87
|
*
|
|
88
|
-
*
|
|
88
|
+
* **Example:**
|
|
89
89
|
* ```tsx
|
|
90
90
|
* <form {...getFormProps(metadata)} />
|
|
91
91
|
* ```
|
|
@@ -101,7 +101,7 @@ export declare function getFormProps<Schema extends Record<string, any>, FormErr
|
|
|
101
101
|
* Derives the properties of a fieldset element based on the field metadata,
|
|
102
102
|
* including `id`, `name`, `form`, and `aria-describedby`.
|
|
103
103
|
*
|
|
104
|
-
*
|
|
104
|
+
* **Example:**
|
|
105
105
|
* ```tsx
|
|
106
106
|
* <fieldset {...getFieldsetProps(metadata)} />
|
|
107
107
|
* ```
|
|
@@ -125,8 +125,9 @@ export declare function getFormControlProps<Schema>(metadata: FieldMetadata<Sche
|
|
|
125
125
|
* Depends on the provided options, it will also set `defaultChecked` / `checked` if it is a checkbox or radio button,
|
|
126
126
|
* or otherwise `defaultValue` / `value`.
|
|
127
127
|
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
128
|
+
* See https://conform.guide/api/react/getInputProps
|
|
129
|
+
*
|
|
130
|
+
* **Example:**
|
|
130
131
|
* ```tsx
|
|
131
132
|
* // To setup an uncontrolled input
|
|
132
133
|
* <input {...getInputProps(metadata, { type: 'text' })} />
|
|
@@ -145,8 +146,9 @@ export declare function getInputProps<Schema, Options extends InputOptions>(meta
|
|
|
145
146
|
* and constraint attributes such as `required` or `multiple`.
|
|
146
147
|
* Depends on the provided options, it will also set `defaultValue` / `value`.
|
|
147
148
|
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
149
|
+
* See https://conform.guide/api/react/getSelectProps
|
|
150
|
+
*
|
|
151
|
+
* **Example:**
|
|
150
152
|
* ```tsx
|
|
151
153
|
* // To setup an uncontrolled select
|
|
152
154
|
* <select {...getSelectProps(metadata)} />
|
|
@@ -161,8 +163,9 @@ export declare function getSelectProps<Schema>(metadata: FieldMetadata<Schema, a
|
|
|
161
163
|
* and constraint attributes such as `required`, `minLength` or `maxLength`.
|
|
162
164
|
* Depends on the provided options, it will also set `defaultValue` / `value`.
|
|
163
165
|
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
+
* See https://conform.guide/api/react/getTextareaProps
|
|
167
|
+
*
|
|
168
|
+
* **Example:**
|
|
166
169
|
* ```tsx
|
|
167
170
|
* // To setup an uncontrolled textarea
|
|
168
171
|
* <textarea {...getTextareaProps(metadata)} />
|
|
@@ -175,8 +178,9 @@ export declare function getTextareaProps<Schema>(metadata: FieldMetadata<Schema,
|
|
|
175
178
|
* Derives the properties of a collection of checkboxes or radio buttons based on the field metadata,
|
|
176
179
|
* including common form control attributes like `key`, `id`, `name`, `form`, `autoFocus`, `aria-invalid`, `aria-describedby` and `required`.
|
|
177
180
|
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
181
|
+
* See https://conform.guide/api/react/getCollectionProps
|
|
182
|
+
*
|
|
183
|
+
* **Example:**
|
|
180
184
|
* ```tsx
|
|
181
185
|
* <fieldset>
|
|
182
186
|
* {getCollectionProps(metadata, {
|
package/dist/helpers.js
CHANGED
|
@@ -38,7 +38,7 @@ function getAriaAttributes(metadata) {
|
|
|
38
38
|
* Derives the properties of a form element based on the form metadata,
|
|
39
39
|
* including `id`, `onSubmit`, `noValidate`, and `aria-describedby`.
|
|
40
40
|
*
|
|
41
|
-
*
|
|
41
|
+
* **Example:**
|
|
42
42
|
* ```tsx
|
|
43
43
|
* <form {...getFormProps(metadata)} />
|
|
44
44
|
* ```
|
|
@@ -55,7 +55,7 @@ function getFormProps(metadata, options) {
|
|
|
55
55
|
* Derives the properties of a fieldset element based on the field metadata,
|
|
56
56
|
* including `id`, `name`, `form`, and `aria-describedby`.
|
|
57
57
|
*
|
|
58
|
-
*
|
|
58
|
+
* **Example:**
|
|
59
59
|
* ```tsx
|
|
60
60
|
* <fieldset {...getFieldsetProps(metadata)} />
|
|
61
61
|
* ```
|
|
@@ -87,8 +87,9 @@ function getFormControlProps(metadata, options) {
|
|
|
87
87
|
* Depends on the provided options, it will also set `defaultChecked` / `checked` if it is a checkbox or radio button,
|
|
88
88
|
* or otherwise `defaultValue` / `value`.
|
|
89
89
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
90
|
+
* See https://conform.guide/api/react/getInputProps
|
|
91
|
+
*
|
|
92
|
+
* **Example:**
|
|
92
93
|
* ```tsx
|
|
93
94
|
* // To setup an uncontrolled input
|
|
94
95
|
* <input {...getInputProps(metadata, { type: 'text' })} />
|
|
@@ -129,8 +130,9 @@ function getInputProps(metadata, options) {
|
|
|
129
130
|
* and constraint attributes such as `required` or `multiple`.
|
|
130
131
|
* Depends on the provided options, it will also set `defaultValue` / `value`.
|
|
131
132
|
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
133
|
+
* See https://conform.guide/api/react/getSelectProps
|
|
134
|
+
*
|
|
135
|
+
* **Example:**
|
|
134
136
|
* ```tsx
|
|
135
137
|
* // To setup an uncontrolled select
|
|
136
138
|
* <select {...getSelectProps(metadata)} />
|
|
@@ -156,8 +158,9 @@ function getSelectProps(metadata) {
|
|
|
156
158
|
* and constraint attributes such as `required`, `minLength` or `maxLength`.
|
|
157
159
|
* Depends on the provided options, it will also set `defaultValue` / `value`.
|
|
158
160
|
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
+
* See https://conform.guide/api/react/getTextareaProps
|
|
162
|
+
*
|
|
163
|
+
* **Example:**
|
|
161
164
|
* ```tsx
|
|
162
165
|
* // To setup an uncontrolled textarea
|
|
163
166
|
* <textarea {...getTextareaProps(metadata)} />
|
|
@@ -182,8 +185,9 @@ function getTextareaProps(metadata) {
|
|
|
182
185
|
* Derives the properties of a collection of checkboxes or radio buttons based on the field metadata,
|
|
183
186
|
* including common form control attributes like `key`, `id`, `name`, `form`, `autoFocus`, `aria-invalid`, `aria-describedby` and `required`.
|
|
184
187
|
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
188
|
+
* See https://conform.guide/api/react/getCollectionProps
|
|
189
|
+
*
|
|
190
|
+
* **Example:**
|
|
187
191
|
* ```tsx
|
|
188
192
|
* <fieldset>
|
|
189
193
|
* {getCollectionProps(metadata, {
|
package/dist/helpers.mjs
CHANGED
|
@@ -34,7 +34,7 @@ function getAriaAttributes(metadata) {
|
|
|
34
34
|
* Derives the properties of a form element based on the form metadata,
|
|
35
35
|
* including `id`, `onSubmit`, `noValidate`, and `aria-describedby`.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
37
|
+
* **Example:**
|
|
38
38
|
* ```tsx
|
|
39
39
|
* <form {...getFormProps(metadata)} />
|
|
40
40
|
* ```
|
|
@@ -51,7 +51,7 @@ function getFormProps(metadata, options) {
|
|
|
51
51
|
* Derives the properties of a fieldset element based on the field metadata,
|
|
52
52
|
* including `id`, `name`, `form`, and `aria-describedby`.
|
|
53
53
|
*
|
|
54
|
-
*
|
|
54
|
+
* **Example:**
|
|
55
55
|
* ```tsx
|
|
56
56
|
* <fieldset {...getFieldsetProps(metadata)} />
|
|
57
57
|
* ```
|
|
@@ -83,8 +83,9 @@ function getFormControlProps(metadata, options) {
|
|
|
83
83
|
* Depends on the provided options, it will also set `defaultChecked` / `checked` if it is a checkbox or radio button,
|
|
84
84
|
* or otherwise `defaultValue` / `value`.
|
|
85
85
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
86
|
+
* See https://conform.guide/api/react/getInputProps
|
|
87
|
+
*
|
|
88
|
+
* **Example:**
|
|
88
89
|
* ```tsx
|
|
89
90
|
* // To setup an uncontrolled input
|
|
90
91
|
* <input {...getInputProps(metadata, { type: 'text' })} />
|
|
@@ -125,8 +126,9 @@ function getInputProps(metadata, options) {
|
|
|
125
126
|
* and constraint attributes such as `required` or `multiple`.
|
|
126
127
|
* Depends on the provided options, it will also set `defaultValue` / `value`.
|
|
127
128
|
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
129
|
+
* See https://conform.guide/api/react/getSelectProps
|
|
130
|
+
*
|
|
131
|
+
* **Example:**
|
|
130
132
|
* ```tsx
|
|
131
133
|
* // To setup an uncontrolled select
|
|
132
134
|
* <select {...getSelectProps(metadata)} />
|
|
@@ -152,8 +154,9 @@ function getSelectProps(metadata) {
|
|
|
152
154
|
* and constraint attributes such as `required`, `minLength` or `maxLength`.
|
|
153
155
|
* Depends on the provided options, it will also set `defaultValue` / `value`.
|
|
154
156
|
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
+
* See https://conform.guide/api/react/getTextareaProps
|
|
158
|
+
*
|
|
159
|
+
* **Example:**
|
|
157
160
|
* ```tsx
|
|
158
161
|
* // To setup an uncontrolled textarea
|
|
159
162
|
* <textarea {...getTextareaProps(metadata)} />
|
|
@@ -178,8 +181,9 @@ function getTextareaProps(metadata) {
|
|
|
178
181
|
* Derives the properties of a collection of checkboxes or radio buttons based on the field metadata,
|
|
179
182
|
* including common form control attributes like `key`, `id`, `name`, `form`, `autoFocus`, `aria-invalid`, `aria-describedby` and `required`.
|
|
180
183
|
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
184
|
+
* See https://conform.guide/api/react/getCollectionProps
|
|
185
|
+
*
|
|
186
|
+
* **Example:**
|
|
183
187
|
* ```tsx
|
|
184
188
|
* <fieldset>
|
|
185
189
|
* {getCollectionProps(metadata, {
|
package/dist/integrations.js
CHANGED
|
@@ -75,17 +75,15 @@ function useInputEvent(onUpdate) {
|
|
|
75
75
|
blur: false
|
|
76
76
|
});
|
|
77
77
|
react.useEffect(() => {
|
|
78
|
-
var createEventListener = listener => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
};
|
|
78
|
+
var createEventListener = (listener, event) => {
|
|
79
|
+
var element = ref.current;
|
|
80
|
+
if (element && event.target === element) {
|
|
81
|
+
eventDispatched.current[listener] = true;
|
|
82
|
+
}
|
|
85
83
|
};
|
|
86
|
-
var inputHandler = createEventListener('change');
|
|
87
|
-
var focusHandler = createEventListener('focus');
|
|
88
|
-
var blurHandler = createEventListener('blur');
|
|
84
|
+
var inputHandler = createEventListener.bind(null, 'change');
|
|
85
|
+
var focusHandler = createEventListener.bind(null, 'focus');
|
|
86
|
+
var blurHandler = createEventListener.bind(null, 'blur');
|
|
89
87
|
document.addEventListener('input', inputHandler, true);
|
|
90
88
|
document.addEventListener('focusin', focusHandler, true);
|
|
91
89
|
document.addEventListener('focusout', blurHandler, true);
|
package/dist/integrations.mjs
CHANGED
|
@@ -71,17 +71,15 @@ function useInputEvent(onUpdate) {
|
|
|
71
71
|
blur: false
|
|
72
72
|
});
|
|
73
73
|
useEffect(() => {
|
|
74
|
-
var createEventListener = listener => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
};
|
|
74
|
+
var createEventListener = (listener, event) => {
|
|
75
|
+
var element = ref.current;
|
|
76
|
+
if (element && event.target === element) {
|
|
77
|
+
eventDispatched.current[listener] = true;
|
|
78
|
+
}
|
|
81
79
|
};
|
|
82
|
-
var inputHandler = createEventListener('change');
|
|
83
|
-
var focusHandler = createEventListener('focus');
|
|
84
|
-
var blurHandler = createEventListener('blur');
|
|
80
|
+
var inputHandler = createEventListener.bind(null, 'change');
|
|
81
|
+
var focusHandler = createEventListener.bind(null, 'focus');
|
|
82
|
+
var blurHandler = createEventListener.bind(null, 'blur');
|
|
85
83
|
document.addEventListener('input', inputHandler, true);
|
|
86
84
|
document.addEventListener('focusin', focusHandler, true);
|
|
87
85
|
document.addEventListener('focusout', blurHandler, true);
|
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.
|
|
6
|
+
"version": "1.19.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.
|
|
44
|
+
"@conform-to/dom": "1.19.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@babel/core": "^7.17.8",
|