@conform-to/react 1.0.2 → 1.0.4

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 CHANGED
@@ -8,7 +8,7 @@
8
8
  ╚══════╝ ╚═════╝ ╚═╝ ╚══╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
9
9
 
10
10
 
11
- Version 1.0.2 / License MIT / Copyright (c) 2024 Edmund Hung
11
+ Version 1.0.3 / License MIT / Copyright (c) 2024 Edmund Hung
12
12
 
13
13
  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.
14
14
 
package/context.d.ts CHANGED
@@ -27,11 +27,11 @@ export type FormMetadata<Schema extends Record<string, unknown> = Record<string,
27
27
  onSubmit: (event: React.FormEvent<HTMLFormElement>) => void;
28
28
  noValidate: boolean;
29
29
  };
30
- type SubfieldMetadata<Schema, FormSchema extends Record<string, any>, FormError, CombinedSchema = Combine<Schema>> = Exclude<Schema, undefined> extends Array<infer Item> ? {
30
+ type SubfieldMetadata<Schema, FormSchema extends Record<string, any>, FormError> = [Schema] extends [Primitive] ? {} : [Schema] extends [Array<infer Item> | null | undefined] ? {
31
31
  getFieldList: () => Array<FieldMetadata<Item, FormSchema, FormError>>;
32
- } : Exclude<Schema, undefined> extends Record<string, unknown> ? {
32
+ } : [Schema] extends [Record<string, any> | null | undefined] ? {
33
33
  getFieldset: () => Required<{
34
- [Key in keyof CombinedSchema]: FieldMetadata<CombinedSchema[Key], FormSchema, FormError>;
34
+ [Key in keyof Combine<Schema>]: FieldMetadata<Combine<Schema>[Key], FormSchema, FormError>;
35
35
  }>;
36
36
  } : {};
37
37
  export type FieldMetadata<Schema = unknown, FormSchema extends Record<string, any> = Record<string, unknown>, FormError = string[]> = Metadata<Schema, FormSchema, FormError> & Constraint & {
package/helpers.d.ts CHANGED
@@ -125,7 +125,7 @@ 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
- * @see https://conform.guide/api/react/get-input-props
128
+ * @see https://conform.guide/api/react/getInputProps
129
129
  * @example
130
130
  * ```tsx
131
131
  * // To setup an uncontrolled input
@@ -145,7 +145,7 @@ export declare function getInputProps<Schema>(metadata: FieldMetadata<Schema, an
145
145
  * and constraint attributes such as `required` or `multiple`.
146
146
  * Depends on the provided options, it will also set `defaultValue` / `value`.
147
147
  *
148
- * @see https://conform.guide/api/react/get-select-props
148
+ * @see https://conform.guide/api/react/getSelectProps
149
149
  * @example
150
150
  * ```tsx
151
151
  * // To setup an uncontrolled select
@@ -161,7 +161,7 @@ export declare function getSelectProps<Schema>(metadata: FieldMetadata<Schema, a
161
161
  * and constraint attributes such as `required`, `minLength` or `maxLength`.
162
162
  * Depends on the provided options, it will also set `defaultValue` / `value`.
163
163
  *
164
- * @see https://conform.guide/api/react/get-textarea-props
164
+ * @see https://conform.guide/api/react/getTextareaProps
165
165
  * @example
166
166
  * ```tsx
167
167
  * // To setup an uncontrolled textarea
@@ -175,7 +175,7 @@ export declare function getTextareaProps<Schema>(metadata: FieldMetadata<Schema,
175
175
  * Derives the properties of a collection of checkboxes or radio buttons based on the field metadata,
176
176
  * including common form control attributes like `key`, `id`, `name`, `form`, `autoFocus`, `aria-invalid`, `aria-describedby` and `required`.
177
177
  *
178
- * @see https://conform.guide/api/react/get-textarea-props
178
+ * @see https://conform.guide/api/react/getTextareaProps
179
179
  * @example
180
180
  * ```tsx
181
181
  * <fieldset>
@@ -201,7 +201,7 @@ export declare function getCollectionProps<Schema extends Array<string | boolean
201
201
  */
202
202
  options: string[];
203
203
  /**
204
- * Decide whether defaultValue should be returned. Pass `false` if you want to mange the value yourself.
204
+ * Decide whether defaultValue should be returned. Pass `false` if you want to manage the value yourself.
205
205
  */
206
206
  value?: boolean;
207
207
  }>): Array<InputProps & Pick<Required<InputProps>, 'type' | 'value'>>;
package/helpers.js CHANGED
@@ -85,7 +85,7 @@ function getFormControlProps(metadata, options) {
85
85
  * Depends on the provided options, it will also set `defaultChecked` / `checked` if it is a checkbox or radio button,
86
86
  * or otherwise `defaultValue` / `value`.
87
87
  *
88
- * @see https://conform.guide/api/react/get-input-props
88
+ * @see https://conform.guide/api/react/getInputProps
89
89
  * @example
90
90
  * ```tsx
91
91
  * // To setup an uncontrolled input
@@ -126,7 +126,7 @@ function getInputProps(metadata, options) {
126
126
  * and constraint attributes such as `required` or `multiple`.
127
127
  * Depends on the provided options, it will also set `defaultValue` / `value`.
128
128
  *
129
- * @see https://conform.guide/api/react/get-select-props
129
+ * @see https://conform.guide/api/react/getSelectProps
130
130
  * @example
131
131
  * ```tsx
132
132
  * // To setup an uncontrolled select
@@ -153,7 +153,7 @@ function getSelectProps(metadata) {
153
153
  * and constraint attributes such as `required`, `minLength` or `maxLength`.
154
154
  * Depends on the provided options, it will also set `defaultValue` / `value`.
155
155
  *
156
- * @see https://conform.guide/api/react/get-textarea-props
156
+ * @see https://conform.guide/api/react/getTextareaProps
157
157
  * @example
158
158
  * ```tsx
159
159
  * // To setup an uncontrolled textarea
@@ -179,7 +179,7 @@ function getTextareaProps(metadata) {
179
179
  * Derives the properties of a collection of checkboxes or radio buttons based on the field metadata,
180
180
  * including common form control attributes like `key`, `id`, `name`, `form`, `autoFocus`, `aria-invalid`, `aria-describedby` and `required`.
181
181
  *
182
- * @see https://conform.guide/api/react/get-textarea-props
182
+ * @see https://conform.guide/api/react/getTextareaProps
183
183
  * @example
184
184
  * ```tsx
185
185
  * <fieldset>
package/helpers.mjs CHANGED
@@ -81,7 +81,7 @@ function getFormControlProps(metadata, options) {
81
81
  * Depends on the provided options, it will also set `defaultChecked` / `checked` if it is a checkbox or radio button,
82
82
  * or otherwise `defaultValue` / `value`.
83
83
  *
84
- * @see https://conform.guide/api/react/get-input-props
84
+ * @see https://conform.guide/api/react/getInputProps
85
85
  * @example
86
86
  * ```tsx
87
87
  * // To setup an uncontrolled input
@@ -122,7 +122,7 @@ function getInputProps(metadata, options) {
122
122
  * and constraint attributes such as `required` or `multiple`.
123
123
  * Depends on the provided options, it will also set `defaultValue` / `value`.
124
124
  *
125
- * @see https://conform.guide/api/react/get-select-props
125
+ * @see https://conform.guide/api/react/getSelectProps
126
126
  * @example
127
127
  * ```tsx
128
128
  * // To setup an uncontrolled select
@@ -149,7 +149,7 @@ function getSelectProps(metadata) {
149
149
  * and constraint attributes such as `required`, `minLength` or `maxLength`.
150
150
  * Depends on the provided options, it will also set `defaultValue` / `value`.
151
151
  *
152
- * @see https://conform.guide/api/react/get-textarea-props
152
+ * @see https://conform.guide/api/react/getTextareaProps
153
153
  * @example
154
154
  * ```tsx
155
155
  * // To setup an uncontrolled textarea
@@ -175,7 +175,7 @@ function getTextareaProps(metadata) {
175
175
  * Derives the properties of a collection of checkboxes or radio buttons based on the field metadata,
176
176
  * including common form control attributes like `key`, `id`, `name`, `form`, `autoFocus`, `aria-invalid`, `aria-describedby` and `required`.
177
177
  *
178
- * @see https://conform.guide/api/react/get-textarea-props
178
+ * @see https://conform.guide/api/react/getTextareaProps
179
179
  * @example
180
180
  * ```tsx
181
181
  * <fieldset>
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.0.2",
6
+ "version": "1.0.4",
7
7
  "main": "index.js",
8
8
  "module": "index.mjs",
9
9
  "types": "index.d.ts",
@@ -30,7 +30,7 @@
30
30
  "url": "https://github.com/edmundhung/conform/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@conform-to/dom": "1.0.2"
33
+ "@conform-to/dom": "1.0.4"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/react": "^18.2.43",