@conform-to/react 1.1.3 → 1.1.5

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/context.d.ts CHANGED
@@ -1,72 +1,200 @@
1
- import { type Constraint, type Combine, type FormId, type FieldName, type FormContext as BaseFormContext, type FormValue, type FormState, type Intent, type SubscriptionScope, type SubscriptionSubject, type FormOptions as BaseFormOptions } from '@conform-to/dom';
2
- import { type FormEvent, type ReactElement, type ReactNode, type MutableRefObject } from 'react';
1
+ import {
2
+ type Constraint,
3
+ type Combine,
4
+ type FormId,
5
+ type FieldName,
6
+ type FormContext as BaseFormContext,
7
+ type FormValue,
8
+ type FormState,
9
+ type Intent,
10
+ type SubscriptionScope,
11
+ type SubscriptionSubject,
12
+ type FormOptions as BaseFormOptions,
13
+ } from '@conform-to/dom';
14
+ import {
15
+ type FormEvent,
16
+ type ReactElement,
17
+ type ReactNode,
18
+ type MutableRefObject,
19
+ } from 'react';
3
20
  export type Pretty<T> = {
4
- [K in keyof T]: T[K];
21
+ [K in keyof T]: T[K];
5
22
  } & {};
6
- export type Primitive = string | number | bigint | boolean | Date | File | null | undefined;
7
- export type Metadata<Schema, FormSchema extends Record<string, unknown>, FormError = string[]> = {
8
- key: string | undefined;
9
- id: string;
10
- errorId: string;
11
- descriptionId: string;
12
- name: FieldName<Schema, FormSchema, FormError>;
13
- initialValue: FormValue<Schema>;
14
- value: FormValue<Schema>;
15
- errors: FormError | undefined;
16
- allErrors: Record<string, FormError>;
17
- valid: boolean;
18
- dirty: boolean;
23
+ export type Primitive =
24
+ | string
25
+ | number
26
+ | bigint
27
+ | boolean
28
+ | Date
29
+ | File
30
+ | null
31
+ | undefined;
32
+ export type Metadata<
33
+ Schema,
34
+ FormSchema extends Record<string, unknown>,
35
+ FormError = string[],
36
+ > = {
37
+ key: string | undefined;
38
+ id: string;
39
+ errorId: string;
40
+ descriptionId: string;
41
+ name: FieldName<Schema, FormSchema, FormError>;
42
+ initialValue: FormValue<Schema>;
43
+ value: FormValue<Schema>;
44
+ errors: FormError | undefined;
45
+ allErrors: Record<string, FormError>;
46
+ valid: boolean;
47
+ dirty: boolean;
19
48
  };
20
- export type FormMetadata<Schema extends Record<string, unknown> = Record<string, unknown>, FormError = string[]> = Omit<Metadata<Schema, Schema, FormError>, 'id'> & Pick<FormContext<Schema, FormError>, Intent['type']> & {
21
- id: FormId<Schema, FormError>;
22
- context: Wrapped<FormContext<Schema, FormError>>;
23
- status?: 'success' | 'error';
24
- getFieldset: () => Required<{
25
- [Key in keyof Combine<Schema>]: FieldMetadata<Combine<Schema>[Key], Schema, FormError>;
26
- }>;
27
- onSubmit: (event: React.FormEvent<HTMLFormElement>) => void;
28
- noValidate: boolean;
29
- };
30
- type SubfieldMetadata<Schema, FormSchema extends Record<string, any>, FormError> = [Schema] extends [Primitive] ? {} : [Schema] extends [Array<infer Item> | null | undefined] ? {
31
- getFieldList: () => Array<FieldMetadata<Item, FormSchema, FormError>>;
32
- } : [Schema] extends [Record<string, any> | null | undefined] ? {
33
- getFieldset: () => Required<{
34
- [Key in keyof Combine<Schema>]: FieldMetadata<Combine<Schema>[Key], FormSchema, FormError>;
35
- }>;
36
- } : {};
37
- export type FieldMetadata<Schema = unknown, FormSchema extends Record<string, any> = Record<string, unknown>, FormError = string[]> = Metadata<Schema, FormSchema, FormError> & Constraint & {
38
- formId: FormId<FormSchema, FormError>;
39
- } & SubfieldMetadata<Schema, FormSchema, FormError>;
40
- export declare const Form: import("react").Context<FormContext<any, string[], any>[]>;
49
+ export type FormMetadata<
50
+ Schema extends Record<string, unknown> = Record<string, unknown>,
51
+ FormError = string[],
52
+ > = Omit<Metadata<Schema, Schema, FormError>, 'id'> &
53
+ Pick<FormContext<Schema, FormError>, Intent['type']> & {
54
+ id: FormId<Schema, FormError>;
55
+ context: Wrapped<FormContext<Schema, FormError>>;
56
+ status?: 'success' | 'error';
57
+ getFieldset: () => Required<{
58
+ [Key in keyof Combine<Schema>]: FieldMetadata<
59
+ Combine<Schema>[Key],
60
+ Schema,
61
+ FormError
62
+ >;
63
+ }>;
64
+ onSubmit: (event: React.FormEvent<HTMLFormElement>) => void;
65
+ noValidate: boolean;
66
+ };
67
+ type SubfieldMetadata<
68
+ Schema,
69
+ FormSchema extends Record<string, any>,
70
+ FormError,
71
+ > = [Schema] extends [Primitive]
72
+ ? {}
73
+ : [Schema] extends [Array<infer Item> | null | undefined]
74
+ ? {
75
+ getFieldList: () => Array<FieldMetadata<Item, FormSchema, FormError>>;
76
+ }
77
+ : [Schema] extends [Record<string, any> | null | undefined]
78
+ ? {
79
+ getFieldset: () => Required<{
80
+ [Key in keyof Combine<Schema>]: FieldMetadata<
81
+ Combine<Schema>[Key],
82
+ FormSchema,
83
+ FormError
84
+ >;
85
+ }>;
86
+ }
87
+ : {};
88
+ export type FieldMetadata<
89
+ Schema = unknown,
90
+ FormSchema extends Record<string, any> = Record<string, unknown>,
91
+ FormError = string[],
92
+ > = Metadata<Schema, FormSchema, FormError> &
93
+ Constraint & {
94
+ formId: FormId<FormSchema, FormError>;
95
+ } & SubfieldMetadata<Schema, FormSchema, FormError>;
96
+ export declare const Form: import('react').Context<
97
+ FormContext<any, string[], any>[]
98
+ >;
41
99
  declare const wrappedSymbol: unique symbol;
42
100
  export type Wrapped<Type> = {
43
- [wrappedSymbol]: Type;
101
+ [wrappedSymbol]: Type;
44
102
  };
45
- export declare function getWrappedFormContext(context: Wrapped<FormContext>): FormContext;
46
- export declare function useFormContext<Schema extends Record<string, any>, FormError>(formId?: FormId<Schema, FormError>): FormContext<Schema, FormError, unknown>;
47
- export declare function useFormState<FormError>(form: FormContext<any, FormError>, subjectRef?: MutableRefObject<SubscriptionSubject>): FormState<FormError>;
103
+ export declare function getWrappedFormContext(
104
+ context: Wrapped<FormContext>,
105
+ ): FormContext;
106
+ export declare function useFormContext<
107
+ Schema extends Record<string, any>,
108
+ FormError,
109
+ >(formId?: FormId<Schema, FormError>): FormContext<Schema, FormError, unknown>;
110
+ export declare function useFormState<FormError>(
111
+ form: FormContext<any, FormError>,
112
+ subjectRef?: MutableRefObject<SubscriptionSubject>,
113
+ ): FormState<FormError>;
48
114
  export declare function FormProvider(props: {
49
- context: Wrapped<FormContext<any, any>>;
50
- children: ReactNode;
115
+ context: Wrapped<FormContext<any, any>>;
116
+ children: ReactNode;
51
117
  }): ReactElement;
52
118
  export declare function FormStateInput(props: {
53
- formId?: string;
119
+ formId?: string;
54
120
  }): React.ReactElement;
55
- export declare function useSubjectRef(initialSubject?: SubscriptionSubject): MutableRefObject<SubscriptionSubject>;
56
- export declare function updateSubjectRef(ref: MutableRefObject<SubscriptionSubject>, subject: 'status' | 'formId'): void;
57
- export declare function updateSubjectRef(ref: MutableRefObject<SubscriptionSubject>, subject: Exclude<keyof SubscriptionSubject, 'status' | 'formId'>, scope: keyof SubscriptionScope, name: string): void;
58
- export declare function getMetadata<Schema, FormError, FormSchema extends Record<string, any>>(context: FormContext<FormSchema, FormError, any>, subjectRef: MutableRefObject<SubscriptionSubject>, stateSnapshot: FormState<FormError>, name?: FieldName<Schema, FormSchema, FormError>): Metadata<Schema, FormSchema, FormError>;
59
- export declare function getFieldMetadata<Schema, FormSchema extends Record<string, any>, FormError>(context: FormContext<FormSchema, FormError, any>, subjectRef: MutableRefObject<SubscriptionSubject>, stateSnapshot: FormState<FormError>, prefix?: string, key?: string | number): FieldMetadata<Schema, FormSchema, FormError>;
60
- export declare function getFormMetadata<Schema extends Record<string, any>, FormError = string[], FormValue = Schema>(context: FormContext<Schema, FormError, FormValue>, subjectRef: MutableRefObject<SubscriptionSubject>, stateSnapshot: FormState<FormError>, noValidate: boolean): FormMetadata<Schema, FormError>;
61
- export type FormOptions<Schema extends Record<string, any> = any, FormError = string[], FormValue = Schema> = BaseFormOptions<Schema, FormError, FormValue> & {
62
- /**
63
- * A function to be called before the form is submitted.
64
- */
65
- onSubmit?: (event: FormEvent<HTMLFormElement>, context: ReturnType<BaseFormContext<Schema, FormError, FormValue>['submit']>) => void;
121
+ export declare function useSubjectRef(
122
+ initialSubject?: SubscriptionSubject,
123
+ ): MutableRefObject<SubscriptionSubject>;
124
+ export declare function updateSubjectRef(
125
+ ref: MutableRefObject<SubscriptionSubject>,
126
+ subject: 'status' | 'formId',
127
+ ): void;
128
+ export declare function updateSubjectRef(
129
+ ref: MutableRefObject<SubscriptionSubject>,
130
+ subject: Exclude<keyof SubscriptionSubject, 'status' | 'formId'>,
131
+ scope: keyof SubscriptionScope,
132
+ name: string,
133
+ ): void;
134
+ export declare function getMetadata<
135
+ Schema,
136
+ FormError,
137
+ FormSchema extends Record<string, any>,
138
+ >(
139
+ context: FormContext<FormSchema, FormError, any>,
140
+ subjectRef: MutableRefObject<SubscriptionSubject>,
141
+ stateSnapshot: FormState<FormError>,
142
+ name?: FieldName<Schema, FormSchema, FormError>,
143
+ ): Metadata<Schema, FormSchema, FormError>;
144
+ export declare function getFieldMetadata<
145
+ Schema,
146
+ FormSchema extends Record<string, any>,
147
+ FormError,
148
+ >(
149
+ context: FormContext<FormSchema, FormError, any>,
150
+ subjectRef: MutableRefObject<SubscriptionSubject>,
151
+ stateSnapshot: FormState<FormError>,
152
+ prefix?: string,
153
+ key?: string | number,
154
+ ): FieldMetadata<Schema, FormSchema, FormError>;
155
+ export declare function getFormMetadata<
156
+ Schema extends Record<string, any>,
157
+ FormError = string[],
158
+ FormValue = Schema,
159
+ >(
160
+ context: FormContext<Schema, FormError, FormValue>,
161
+ subjectRef: MutableRefObject<SubscriptionSubject>,
162
+ stateSnapshot: FormState<FormError>,
163
+ noValidate: boolean,
164
+ ): FormMetadata<Schema, FormError>;
165
+ export type FormOptions<
166
+ Schema extends Record<string, any> = any,
167
+ FormError = string[],
168
+ FormValue = Schema,
169
+ > = BaseFormOptions<Schema, FormError, FormValue> & {
170
+ /**
171
+ * A function to be called before the form is submitted.
172
+ */
173
+ onSubmit?: (
174
+ event: FormEvent<HTMLFormElement>,
175
+ context: ReturnType<
176
+ BaseFormContext<Schema, FormError, FormValue>['submit']
177
+ >,
178
+ ) => void;
66
179
  };
67
- export type FormContext<Schema extends Record<string, any> = any, FormError = string[], FormValue = Schema> = Omit<BaseFormContext<Schema, FormError, FormValue>, 'submit' | 'onUpdate'> & {
68
- submit: (event: FormEvent<HTMLFormElement>) => void;
69
- onUpdate: (options: Partial<FormOptions<Schema, FormError, FormValue>>) => void;
180
+ export type FormContext<
181
+ Schema extends Record<string, any> = any,
182
+ FormError = string[],
183
+ FormValue = Schema,
184
+ > = Omit<
185
+ BaseFormContext<Schema, FormError, FormValue>,
186
+ 'submit' | 'onUpdate'
187
+ > & {
188
+ submit: (event: FormEvent<HTMLFormElement>) => void;
189
+ onUpdate: (
190
+ options: Partial<FormOptions<Schema, FormError, FormValue>>,
191
+ ) => void;
70
192
  };
71
- export declare function createFormContext<Schema extends Record<string, any> = any, FormError = string[], FormValue = Schema>(options: FormOptions<Schema, FormError, FormValue>): FormContext<Schema, FormError, FormValue>;
193
+ export declare function createFormContext<
194
+ Schema extends Record<string, any> = any,
195
+ FormError = string[],
196
+ FormValue = Schema,
197
+ >(
198
+ options: FormOptions<Schema, FormError, FormValue>,
199
+ ): FormContext<Schema, FormError, FormValue>;
72
200
  export {};
package/context.js CHANGED
@@ -7,7 +7,6 @@ var dom = require('@conform-to/dom');
7
7
  var react = require('react');
8
8
  var jsxRuntime = require('react/jsx-runtime');
9
9
 
10
- var _excluded = ["onSubmit"];
11
10
  var Form = /*#__PURE__*/react.createContext([]);
12
11
 
13
12
  // To hide the FormContext type from the public API
@@ -220,10 +219,9 @@ function getFormMetadata(context, subjectRef, stateSnapshot, noValidate) {
220
219
  }
221
220
  function createFormContext(options) {
222
221
  var {
223
- onSubmit
224
- } = options,
225
- rest = _rollupPluginBabelHelpers.objectWithoutProperties(options, _excluded);
226
- var context = dom.unstable_createFormContext(rest);
222
+ onSubmit
223
+ } = options;
224
+ var context = dom.unstable_createFormContext(options);
227
225
  return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, context), {}, {
228
226
  submit(event) {
229
227
  var submitEvent = event.nativeEvent;
package/context.mjs CHANGED
@@ -1,9 +1,8 @@
1
- import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from './_virtual/_rollupPluginBabelHelpers.mjs';
1
+ import { objectSpread2 as _objectSpread2 } from './_virtual/_rollupPluginBabelHelpers.mjs';
2
2
  import { STATE, formatPaths, getPaths, unstable_createFormContext, INTENT, isPrefix } from '@conform-to/dom';
3
3
  import { useContext, useMemo, createContext, useCallback, useSyncExternalStore, useRef } from 'react';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
 
6
- var _excluded = ["onSubmit"];
7
6
  var Form = /*#__PURE__*/createContext([]);
8
7
 
9
8
  // To hide the FormContext type from the public API
@@ -216,10 +215,9 @@ function getFormMetadata(context, subjectRef, stateSnapshot, noValidate) {
216
215
  }
217
216
  function createFormContext(options) {
218
217
  var {
219
- onSubmit
220
- } = options,
221
- rest = _objectWithoutProperties(options, _excluded);
222
- var context = unstable_createFormContext(rest);
218
+ onSubmit
219
+ } = options;
220
+ var context = unstable_createFormContext(options);
223
221
  return _objectSpread2(_objectSpread2({}, context), {}, {
224
222
  submit(event) {
225
223
  var submitEvent = event.nativeEvent;
File without changes
package/helpers.js CHANGED
@@ -112,7 +112,7 @@ function getInputProps(metadata, options) {
112
112
  if (typeof options.value === 'undefined' || options.value) {
113
113
  if (options.type === 'checkbox' || options.type === 'radio') {
114
114
  props.value = typeof options.value === 'string' ? options.value : 'on';
115
- props.defaultChecked = typeof metadata.initialValue === 'boolean' ? metadata.initialValue : metadata.initialValue === props.value;
115
+ props.defaultChecked = Array.isArray(metadata.initialValue) ? metadata.initialValue.includes(options.value) : metadata.initialValue === props.value;
116
116
  } else if (typeof metadata.initialValue === 'string') {
117
117
  props.defaultValue = metadata.initialValue;
118
118
  }
package/helpers.mjs CHANGED
@@ -108,7 +108,7 @@ function getInputProps(metadata, options) {
108
108
  if (typeof options.value === 'undefined' || options.value) {
109
109
  if (options.type === 'checkbox' || options.type === 'radio') {
110
110
  props.value = typeof options.value === 'string' ? options.value : 'on';
111
- props.defaultChecked = typeof metadata.initialValue === 'boolean' ? metadata.initialValue : metadata.initialValue === props.value;
111
+ props.defaultChecked = Array.isArray(metadata.initialValue) ? metadata.initialValue.includes(options.value) : metadata.initialValue === props.value;
112
112
  } else if (typeof metadata.initialValue === 'string') {
113
113
  props.defaultValue = metadata.initialValue;
114
114
  }
package/hooks.d.ts CHANGED
@@ -1,34 +1,63 @@
1
1
  import { type FormId, type FieldName } from '@conform-to/dom';
2
2
  import { useEffect } from 'react';
3
- import { type FormMetadata, type FieldMetadata, type Pretty, type FormOptions } from './context';
3
+ import {
4
+ type FormMetadata,
5
+ type FieldMetadata,
6
+ type Pretty,
7
+ type FormOptions,
8
+ } from './context';
4
9
  /**
5
10
  * useLayoutEffect is client-only.
6
11
  * This basically makes it a no-op on server
7
12
  */
8
13
  export declare const useSafeLayoutEffect: typeof useEffect;
9
- export declare function useFormId<Schema extends Record<string, unknown>, FormError>(preferredId?: string): FormId<Schema, FormError>;
14
+ export declare function useFormId<
15
+ Schema extends Record<string, unknown>,
16
+ FormError,
17
+ >(preferredId?: string): FormId<Schema, FormError>;
10
18
  export declare function useNoValidate(defaultNoValidate?: boolean): boolean;
11
- export declare function useForm<Schema extends Record<string, any>, FormValue = Schema, FormError = string[]>(options: Pretty<Omit<FormOptions<Schema, FormError, FormValue>, 'formId'> & {
12
- /**
13
- * The form id. If not provided, a random id will be generated.
14
- */
15
- id?: string;
16
- /**
17
- * Enable constraint validation before the dom is hydated.
18
- *
19
- * Default to `true`.
20
- */
21
- defaultNoValidate?: boolean;
22
- }>): [
23
- FormMetadata<Schema, FormError>,
24
- ReturnType<FormMetadata<Schema, FormError>['getFieldset']>
19
+ export declare function useForm<
20
+ Schema extends Record<string, any>,
21
+ FormValue = Schema,
22
+ FormError = string[],
23
+ >(
24
+ options: Pretty<
25
+ Omit<FormOptions<Schema, FormError, FormValue>, 'formId'> & {
26
+ /**
27
+ * The form id. If not provided, a random id will be generated.
28
+ */
29
+ id?: string;
30
+ /**
31
+ * Enable constraint validation before the dom is hydated.
32
+ *
33
+ * Default to `true`.
34
+ */
35
+ defaultNoValidate?: boolean;
36
+ }
37
+ >,
38
+ ): [
39
+ FormMetadata<Schema, FormError>,
40
+ ReturnType<FormMetadata<Schema, FormError>['getFieldset']>,
25
41
  ];
26
- export declare function useFormMetadata<Schema extends Record<string, any>, FormError = string[]>(formId?: FormId<Schema, FormError>, options?: {
27
- defaultNoValidate?: boolean;
28
- }): FormMetadata<Schema, FormError>;
29
- export declare function useField<FieldSchema, FormSchema extends Record<string, unknown> = Record<string, unknown>, FormError = string[]>(name: FieldName<FieldSchema, FormSchema, FormError>, options?: {
30
- formId?: FormId<FormSchema, FormError>;
31
- }): [
32
- FieldMetadata<FieldSchema, FormSchema, FormError>,
33
- FormMetadata<FormSchema, FormError>
42
+ export declare function useFormMetadata<
43
+ Schema extends Record<string, any>,
44
+ FormError = string[],
45
+ >(
46
+ formId?: FormId<Schema, FormError>,
47
+ options?: {
48
+ defaultNoValidate?: boolean;
49
+ },
50
+ ): FormMetadata<Schema, FormError>;
51
+ export declare function useField<
52
+ FieldSchema,
53
+ FormSchema extends Record<string, unknown> = Record<string, unknown>,
54
+ FormError = string[],
55
+ >(
56
+ name: FieldName<FieldSchema, FormSchema, FormError>,
57
+ options?: {
58
+ formId?: FormId<FormSchema, FormError>;
59
+ },
60
+ ): [
61
+ FieldMetadata<FieldSchema, FormSchema, FormError>,
62
+ FormMetadata<FormSchema, FormError>,
34
63
  ];
package/index.d.ts CHANGED
@@ -1,5 +1,29 @@
1
- export { type Submission, type SubmissionResult, type DefaultValue, type Intent, type FormId, type FieldName, parse, } from '@conform-to/dom';
2
- export { type FieldMetadata, type FormMetadata, FormProvider, FormStateInput, } from './context';
1
+ export {
2
+ type Submission,
3
+ type SubmissionResult,
4
+ type DefaultValue,
5
+ type Intent,
6
+ type FormId,
7
+ type FieldName,
8
+ parse,
9
+ } from '@conform-to/dom';
10
+ export {
11
+ type FieldMetadata,
12
+ type FormMetadata,
13
+ FormProvider,
14
+ FormStateInput,
15
+ } from './context';
3
16
  export { useForm, useFormMetadata, useField } from './hooks';
4
- export { Control as unstable_Control, useControl as unstable_useControl, useInputControl, } from './integrations';
5
- export { getFormProps, getFieldsetProps, getInputProps, getSelectProps, getTextareaProps, getCollectionProps, } from './helpers';
17
+ export {
18
+ Control as unstable_Control,
19
+ useControl as unstable_useControl,
20
+ useInputControl,
21
+ } from './integrations';
22
+ export {
23
+ getFormProps,
24
+ getFieldsetProps,
25
+ getInputProps,
26
+ getSelectProps,
27
+ getTextareaProps,
28
+ getCollectionProps,
29
+ } from './helpers';
package/integrations.js CHANGED
@@ -216,8 +216,21 @@ function useControl(meta) {
216
216
  setValue(value);
217
217
  change(value);
218
218
  };
219
+ var refCallback = element => {
220
+ var _meta$key;
221
+ register(element);
222
+ if (!element) {
223
+ return;
224
+ }
225
+ var prevKey = element.dataset.conform;
226
+ var nextKey = "".concat((_meta$key = meta.key) !== null && _meta$key !== void 0 ? _meta$key : '');
227
+ if (prevKey !== nextKey) {
228
+ element.dataset.conform = nextKey;
229
+ updateFieldValue(element, value !== null && value !== void 0 ? value : '');
230
+ }
231
+ };
219
232
  return {
220
- register,
233
+ register: refCallback,
221
234
  value,
222
235
  change: handleChange,
223
236
  focus,
package/integrations.mjs CHANGED
@@ -212,8 +212,21 @@ function useControl(meta) {
212
212
  setValue(value);
213
213
  change(value);
214
214
  };
215
+ var refCallback = element => {
216
+ var _meta$key;
217
+ register(element);
218
+ if (!element) {
219
+ return;
220
+ }
221
+ var prevKey = element.dataset.conform;
222
+ var nextKey = "".concat((_meta$key = meta.key) !== null && _meta$key !== void 0 ? _meta$key : '');
223
+ if (prevKey !== nextKey) {
224
+ element.dataset.conform = nextKey;
225
+ updateFieldValue(element, value !== null && value !== void 0 ? value : '');
226
+ }
227
+ };
215
228
  return {
216
- register,
229
+ register: refCallback,
217
230
  value,
218
231
  change: handleChange,
219
232
  focus,
package/package.json CHANGED
@@ -1,70 +1,69 @@
1
1
  {
2
- "name": "@conform-to/react",
3
- "description": "Conform view adapter for react",
4
- "homepage": "https://conform.guide",
5
- "license": "MIT",
6
- "version": "1.1.3",
7
- "main": "index.js",
8
- "module": "index.mjs",
9
- "types": "index.d.ts",
10
- "exports": {
11
- ".": {
12
- "types": "./index.d.ts",
13
- "module": "./index.mjs",
14
- "import": "./index.mjs",
15
- "require": "./index.js",
16
- "default": "./index.mjs"
17
- }
18
- },
19
- "scripts": {
20
- "build:js": "rollup -c",
21
- "build:ts": "tsc",
22
- "build": "pnpm run \"/^build:.*/\"",
23
- "dev:js": "pnpm run build:js --watch",
24
- "dev:ts": "pnpm run build:ts --watch",
25
- "dev": "pnpm run \"/^dev:.*/\"",
26
- "prepare": "pnpm run build"
27
- },
28
- "repository": {
29
- "type": "git",
30
- "url": "https://github.com/edmundhung/conform",
31
- "directory": "packages/conform-react"
32
- },
33
- "author": {
34
- "name": "Edmund Hung",
35
- "email": "me@edmund.dev",
36
- "url": "https://edmund.dev"
37
- },
38
- "bugs": {
39
- "url": "https://github.com/edmundhung/conform/issues"
40
- },
41
- "dependencies": {
42
- "@conform-to/dom": "1.1.3"
43
- },
44
- "devDependencies": {
45
- "@babel/core": "^7.17.8",
46
- "@babel/preset-env": "^7.20.2",
47
- "@babel/preset-react": "^7.18.6",
48
- "@babel/preset-typescript": "^7.20.2",
49
- "@rollup/plugin-babel": "^5.3.1",
50
- "@rollup/plugin-node-resolve": "^13.3.0",
51
- "@types/react": "^18.2.43",
52
- "react": "^18.2.0",
53
- "rollup-plugin-copy": "^3.4.0",
54
- "rollup": "^2.79.1"
55
- },
56
- "peerDependencies": {
57
- "react": ">=18"
58
- },
59
- "keywords": [
60
- "constraint-validation",
61
- "form",
62
- "form-validation",
63
- "html",
64
- "progressive-enhancement",
65
- "validation",
66
- "react",
67
- "remix"
68
- ],
69
- "sideEffects": false
70
- }
2
+ "name": "@conform-to/react",
3
+ "description": "Conform view adapter for react",
4
+ "homepage": "https://conform.guide",
5
+ "license": "MIT",
6
+ "version": "1.1.5",
7
+ "main": "index.js",
8
+ "module": "index.mjs",
9
+ "types": "index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./index.d.ts",
13
+ "module": "./index.mjs",
14
+ "import": "./index.mjs",
15
+ "require": "./index.js",
16
+ "default": "./index.mjs"
17
+ }
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/edmundhung/conform",
22
+ "directory": "packages/conform-react"
23
+ },
24
+ "author": {
25
+ "name": "Edmund Hung",
26
+ "email": "me@edmund.dev",
27
+ "url": "https://edmund.dev"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/edmundhung/conform/issues"
31
+ },
32
+ "dependencies": {
33
+ "@conform-to/dom": "1.1.5"
34
+ },
35
+ "devDependencies": {
36
+ "@babel/core": "^7.17.8",
37
+ "@babel/preset-env": "^7.20.2",
38
+ "@babel/preset-react": "^7.18.6",
39
+ "@babel/preset-typescript": "^7.20.2",
40
+ "@rollup/plugin-babel": "^5.3.1",
41
+ "@rollup/plugin-node-resolve": "^13.3.0",
42
+ "@types/react": "^18.2.43",
43
+ "react": "^18.2.0",
44
+ "rollup-plugin-copy": "^3.4.0",
45
+ "rollup": "^2.79.1"
46
+ },
47
+ "peerDependencies": {
48
+ "react": ">=18"
49
+ },
50
+ "keywords": [
51
+ "constraint-validation",
52
+ "form",
53
+ "form-validation",
54
+ "html",
55
+ "progressive-enhancement",
56
+ "validation",
57
+ "react",
58
+ "remix"
59
+ ],
60
+ "sideEffects": false,
61
+ "scripts": {
62
+ "build:js": "rollup -c",
63
+ "build:ts": "tsc",
64
+ "build": "pnpm run \"/^build:.*/\"",
65
+ "dev:js": "pnpm run build:js --watch",
66
+ "dev:ts": "pnpm run build:ts --watch",
67
+ "dev": "pnpm run \"/^dev:.*/\""
68
+ }
69
+ }
package/rollup.config.js DELETED
@@ -1,102 +0,0 @@
1
- import path from 'node:path';
2
- import babel from '@rollup/plugin-babel';
3
- import nodeResolve from '@rollup/plugin-node-resolve';
4
- import copy from 'rollup-plugin-copy';
5
-
6
- /** @returns {import("rollup").RollupOptions[]} */
7
- function configurePackage() {
8
- let sourceDir = '.';
9
- let outputDir = sourceDir;
10
-
11
- /** @type {import("rollup").RollupOptions} */
12
- let ESM = {
13
- external(id) {
14
- return !id.startsWith('.') && !path.isAbsolute(id);
15
- },
16
- input: `${sourceDir}/index.ts`,
17
- output: {
18
- dir: outputDir,
19
- format: 'esm',
20
- preserveModules: true,
21
- entryFileNames: '[name].mjs',
22
- },
23
- plugins: [
24
- babel({
25
- babelrc: false,
26
- configFile: false,
27
- presets: [
28
- [
29
- '@babel/preset-env',
30
- {
31
- targets: {
32
- node: '16',
33
- esmodules: true,
34
- },
35
- },
36
- ],
37
- ['@babel/preset-react', { runtime: 'automatic' }],
38
- '@babel/preset-typescript',
39
- ],
40
- plugins: [],
41
- babelHelpers: 'bundled',
42
- exclude: /node_modules/,
43
- extensions: ['.ts', '.tsx'],
44
- }),
45
- nodeResolve({
46
- extensions: ['.ts', '.tsx'],
47
- }),
48
- copy({
49
- targets: [
50
- { src: `../../README`, dest: sourceDir },
51
- { src: `../../LICENSE`, dest: sourceDir },
52
- ],
53
- }),
54
- ],
55
- };
56
-
57
- /** @type {import("rollup").RollupOptions} */
58
- let CJS = {
59
- external(id) {
60
- return !id.startsWith('.') && !path.isAbsolute(id);
61
- },
62
- input: `${sourceDir}/index.ts`,
63
- output: {
64
- dir: outputDir,
65
- format: 'cjs',
66
- preserveModules: true,
67
- exports: 'auto',
68
- },
69
- plugins: [
70
- babel({
71
- babelrc: false,
72
- configFile: false,
73
- presets: [
74
- [
75
- '@babel/preset-env',
76
- {
77
- targets: {
78
- node: '16',
79
- esmodules: true,
80
- },
81
- },
82
- ],
83
- ['@babel/preset-react', { runtime: 'automatic' }],
84
- '@babel/preset-typescript',
85
- ],
86
- plugins: [],
87
- babelHelpers: 'bundled',
88
- exclude: /node_modules/,
89
- extensions: ['.ts', '.tsx'],
90
- }),
91
- nodeResolve({
92
- extensions: ['.ts', '.tsx'],
93
- }),
94
- ],
95
- };
96
-
97
- return [ESM, CJS];
98
- }
99
-
100
- export default function rollup() {
101
- return configurePackage();
102
- }