diff --git a/packages/conform-dom/form.ts b/packages/conform-dom/form.ts index d7dd53e5..4ac5a7a6 100644 --- a/packages/conform-dom/form.ts +++ b/packages/conform-dom/form.ts @@ -623,7 +623,7 @@ function shouldNotify( return false; } -export function createFormContext< +export function unstable_createFormContext< Schema extends Record, FormError = string[], FormValue = Schema, diff --git a/packages/conform-dom/index.ts b/packages/conform-dom/index.ts index 50f57c5c..1dac09b2 100644 --- a/packages/conform-dom/index.ts +++ b/packages/conform-dom/index.ts @@ -11,7 +11,7 @@ export { type FormContext, type SubscriptionSubject, type SubscriptionScope, - createFormContext as unstable_createFormContext, + unstable_createFormContext, } from './form'; export { type FieldElement, isFieldElement } from './dom'; export { diff --git a/packages/conform-dom/package.json b/packages/conform-dom/package.json index cce67c2e..7dcdd95c 100644 --- a/packages/conform-dom/package.json +++ b/packages/conform-dom/package.json @@ -18,12 +18,13 @@ }, "scripts": { "build:js": "rollup -c", - "build:ts": "tsc", + "build:ts": "tsc --emitDeclarationOnly", "build": "pnpm run \"/^build:.*/\"", "dev:js": "pnpm run build:js --watch", "dev:ts": "pnpm run build:ts --watch", "dev": "pnpm run \"/^dev:.*/\"", - "prepare": "pnpm run build" + "prepare": "pnpm run build", + "typecheck": "tsc --noEmit" }, "repository": { "type": "git", diff --git a/packages/conform-dom/submission.ts b/packages/conform-dom/submission.ts index 9cdf9409..51c79641 100644 --- a/packages/conform-dom/submission.ts +++ b/packages/conform-dom/submission.ts @@ -14,7 +14,7 @@ export type SubmissionState = { validated: Record; }; -export type SubmissionContext = { +export type SubmissionContext = { intent: Intent | null; payload: Record; fields: Set; diff --git a/packages/conform-dom/tsconfig.json b/packages/conform-dom/tsconfig.json index b9d06c58..2bd94b5b 100644 --- a/packages/conform-dom/tsconfig.json +++ b/packages/conform-dom/tsconfig.json @@ -8,7 +8,6 @@ "noUncheckedIndexedAccess": true, "strict": true, "declaration": true, - "emitDeclarationOnly": true, "composite": true, "skipLibCheck": true } diff --git a/packages/conform-react/context.tsx b/packages/conform-react/context.tsx index 9993612b..47d39de7 100644 --- a/packages/conform-react/context.tsx +++ b/packages/conform-react/context.tsx @@ -10,7 +10,7 @@ import { type SubscriptionScope, type SubscriptionSubject, type FormOptions as BaseFormOptions, - unstable_createFormContext as createBaseFormContext, + unstable_createFormContext, formatPaths, getPaths, isPrefix, @@ -18,10 +18,6 @@ import { INTENT, } from '@conform-to/dom'; import { - type FormEvent, - type ReactElement, - type ReactNode, - type MutableRefObject, createContext, useMemo, useCallback, @@ -32,15 +28,7 @@ import { export type Pretty = { [K in keyof T]: T[K] } & {}; -export type Primitive = - | string - | number - | bigint - | boolean - | Date - | File - | null - | undefined; +export type Primitive = string | number | bigint | boolean | null | undefined; export type Metadata< Schema, @@ -83,7 +71,7 @@ type SubfieldMetadata< Schema, FormSchema extends Record, FormError, -> = [Schema] extends [Primitive] +> = [Schema] extends [Primitive | Date | File] ? {} : [Schema] extends [Array | null | undefined] ? { @@ -144,7 +132,7 @@ export function useFormContext, FormError>( export function useFormState( form: FormContext, - subjectRef?: MutableRefObject, + subjectRef?: React.MutableRefObject, ): FormState { const subscribe = useCallback( (callback: () => void) => @@ -157,8 +145,8 @@ export function useFormState( export function FormProvider(props: { context: Wrapped>; - children: ReactNode; -}): ReactElement { + children: React.ReactNode; +}): React.ReactElement { const forms = useContext(Form); const context = getWrappedFormContext(props.context); const value = useMemo( @@ -184,7 +172,7 @@ export function FormStateInput(props: { formId?: string }): React.ReactElement { export function useSubjectRef( initialSubject: SubscriptionSubject = {}, -): MutableRefObject { +): React.MutableRefObject { const subjectRef = useRef(initialSubject); // Reset the subject everytime the component is rerendered @@ -195,17 +183,17 @@ export function useSubjectRef( } export function updateSubjectRef( - ref: MutableRefObject, + ref: React.MutableRefObject, subject: 'status' | 'formId', ): void; export function updateSubjectRef( - ref: MutableRefObject, + ref: React.MutableRefObject, subject: Exclude, scope: keyof SubscriptionScope, name: string, ): void; export function updateSubjectRef( - ref: MutableRefObject, + ref: React.MutableRefObject, subject: keyof SubscriptionSubject, scope?: keyof SubscriptionScope, name?: string, @@ -226,7 +214,7 @@ export function getMetadata< FormSchema extends Record, >( context: FormContext, - subjectRef: MutableRefObject, + subjectRef: React.MutableRefObject, stateSnapshot: FormState, name: FieldName = '', ): Metadata { @@ -272,24 +260,6 @@ export function getMetadata< return result; }, - get getFieldset() { - return () => - new Proxy({} as any, { - get(target, key, receiver) { - if (typeof key === 'string') { - return getFieldMetadata( - context, - subjectRef, - stateSnapshot, - name, - key, - ); - } - - return Reflect.get(target, key, receiver); - }, - }); - }, }, { get(target, key, receiver) { @@ -334,7 +304,7 @@ export function getFieldMetadata< FormError, >( context: FormContext, - subjectRef: MutableRefObject, + subjectRef: React.MutableRefObject, stateSnapshot: FormState, prefix = '', key?: string | number, @@ -404,7 +374,7 @@ export function getFormMetadata< FormValue = Schema, >( context: FormContext, - subjectRef: MutableRefObject, + subjectRef: React.MutableRefObject, stateSnapshot: FormState, noValidate: boolean, ): FormMetadata { @@ -450,7 +420,7 @@ export type FormOptions< * A function to be called before the form is submitted. */ onSubmit?: ( - event: FormEvent, + event: React.FormEvent, context: ReturnType< BaseFormContext['submit'] >, @@ -465,7 +435,7 @@ export type FormContext< BaseFormContext, 'submit' | 'onUpdate' > & { - submit: (event: FormEvent) => void; + submit: (event: React.FormEvent) => void; onUpdate: ( options: Partial>, ) => void; @@ -479,7 +449,7 @@ export function createFormContext< options: FormOptions, ): FormContext { let { onSubmit, ...rest } = options; - const context = createBaseFormContext(rest); + const context = unstable_createFormContext(rest); return { ...context, diff --git a/packages/conform-react/index.ts b/packages/conform-react/index.ts index 01eb81bd..a7ef1594 100644 --- a/packages/conform-react/index.ts +++ b/packages/conform-react/index.ts @@ -15,8 +15,8 @@ export { } from './context'; export { useForm, useFormMetadata, useField } from './hooks'; export { - Control as unstable_Control, - useControl as unstable_useControl, + unstable_Control, + unstable_useControl, useInputControl, } from './integrations'; export { diff --git a/packages/conform-react/integrations.ts b/packages/conform-react/integrations.ts index eb9f5f57..f5dd4771 100644 --- a/packages/conform-react/integrations.ts +++ b/packages/conform-react/integrations.ts @@ -294,10 +294,12 @@ export function useInputValue< return [value, setValue] as const; } -export function useControl< +export function unstable_useControl< Value extends string | string[] | Array, >(meta: { key?: Key | null | undefined; initialValue?: Value | undefined }) { + // eslint-disable-next-line react-hooks/rules-of-hooks const [value, setValue] = useInputValue(meta); + // eslint-disable-next-line react-hooks/rules-of-hooks const { register, change, focus, blur } = useInputEvent(); const handleChange = ( value: Value extends string ? Value : string | string[], @@ -377,13 +379,15 @@ export function useInputControl< }; } -export function Control< +export function unstable_Control< Value extends string | string[] | Array, >(props: { meta: { key?: Key | null | undefined; initialValue?: Value | undefined }; - render: (control: ReturnType>) => React.ReactNode; + render: ( + control: ReturnType>, + ) => React.ReactNode; }) { - const control = useControl(props.meta); + const control = unstable_useControl(props.meta); return props.render(control); } diff --git a/packages/conform-react/package.json b/packages/conform-react/package.json index e1274412..d3987caf 100644 --- a/packages/conform-react/package.json +++ b/packages/conform-react/package.json @@ -18,12 +18,13 @@ }, "scripts": { "build:js": "rollup -c", - "build:ts": "tsc", + "build:ts": "tsc --emitDeclarationOnly", "build": "pnpm run \"/^build:.*/\"", "dev:js": "pnpm run build:js --watch", "dev:ts": "pnpm run build:ts --watch", "dev": "pnpm run \"/^dev:.*/\"", - "prepare": "pnpm run build" + "prepare": "pnpm run build", + "typecheck": "tsc --noEmit" }, "repository": { "type": "git", diff --git a/packages/conform-react/tsconfig.json b/packages/conform-react/tsconfig.json index 2216c8e5..3dc0d918 100644 --- a/packages/conform-react/tsconfig.json +++ b/packages/conform-react/tsconfig.json @@ -9,7 +9,6 @@ "noUncheckedIndexedAccess": true, "strict": true, "declaration": true, - "emitDeclarationOnly": true, "composite": true, "skipLibCheck": true } diff --git a/packages/conform-validitystate/package.json b/packages/conform-validitystate/package.json index a7d2a54f..635623bd 100644 --- a/packages/conform-validitystate/package.json +++ b/packages/conform-validitystate/package.json @@ -18,12 +18,13 @@ }, "scripts": { "build:js": "rollup -c", - "build:ts": "tsc", + "build:ts": "tsc --emitDeclarationOnly", "build": "pnpm run \"/^build:.*/\"", "dev:js": "pnpm run build:js --watch", "dev:ts": "pnpm run build:ts --watch", "dev": "pnpm run \"/^dev:.*/\"", - "prepare": "pnpm run build" + "prepare": "pnpm run build", + "typecheck": "tsc --noEmit" }, "repository": { "type": "git", diff --git a/packages/conform-validitystate/tsconfig.json b/packages/conform-validitystate/tsconfig.json index 0bea9526..a466a381 100644 --- a/packages/conform-validitystate/tsconfig.json +++ b/packages/conform-validitystate/tsconfig.json @@ -7,7 +7,6 @@ "allowSyntheticDefaultImports": true, "strict": true, "declaration": true, - "emitDeclarationOnly": true, "composite": true, "skipLibCheck": true } diff --git a/packages/conform-yup/package.json b/packages/conform-yup/package.json index ed3a7a5c..c62e85b3 100644 --- a/packages/conform-yup/package.json +++ b/packages/conform-yup/package.json @@ -18,12 +18,13 @@ }, "scripts": { "build:js": "rollup -c", - "build:ts": "tsc", + "build:ts": "tsc --emitDeclarationOnly", "build": "pnpm run \"/^build:.*/\"", "dev:js": "pnpm run build:js --watch", "dev:ts": "pnpm run build:ts --watch", "dev": "pnpm run \"/^dev:.*/\"", - "prepare": "pnpm run build" + "prepare": "pnpm run build", + "typecheck": "tsc --noEmit" }, "repository": { "type": "git", diff --git a/packages/conform-yup/tsconfig.json b/packages/conform-yup/tsconfig.json index b9d06c58..2bd94b5b 100644 --- a/packages/conform-yup/tsconfig.json +++ b/packages/conform-yup/tsconfig.json @@ -8,7 +8,6 @@ "noUncheckedIndexedAccess": true, "strict": true, "declaration": true, - "emitDeclarationOnly": true, "composite": true, "skipLibCheck": true } diff --git a/packages/conform-zod/package.json b/packages/conform-zod/package.json index 93bdb687..39817ec2 100644 --- a/packages/conform-zod/package.json +++ b/packages/conform-zod/package.json @@ -18,12 +18,13 @@ }, "scripts": { "build:js": "rollup -c", - "build:ts": "tsc", + "build:ts": "tsc --emitDeclarationOnly", "build": "pnpm run \"/^build:.*/\"", "dev:js": "pnpm run build:js --watch", "dev:ts": "pnpm run build:ts --watch", "dev": "pnpm run \"/^dev:.*/\"", - "prepare": "pnpm run build" + "prepare": "pnpm run build", + "typecheck": "tsc --noEmit" }, "repository": { "type": "git", diff --git a/packages/conform-zod/tsconfig.json b/packages/conform-zod/tsconfig.json index b9d06c58..2bd94b5b 100644 --- a/packages/conform-zod/tsconfig.json +++ b/packages/conform-zod/tsconfig.json @@ -8,7 +8,6 @@ "noUncheckedIndexedAccess": true, "strict": true, "declaration": true, - "emitDeclarationOnly": true, "composite": true, "skipLibCheck": true } diff --git a/tsconfig.json b/tsconfig.json index e7db5e2f..2d25be16 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,10 @@ { "references": [ - { "path": "packages/conform-dom" }, - { "path": "packages/conform-yup" }, - { "path": "packages/conform-zod" }, - { "path": "packages/conform-react" }, - { "path": "packages/conform-validitystate" } + { "path": "./packages/conform-dom" }, + { "path": "./packages/conform-yup" }, + { "path": "./packages/conform-zod" }, + { "path": "./packages/conform-react" }, + { "path": "./packages/conform-validitystate" } ], "files": [] }