@railway-ts/use-form 0.1.18 → 0.1.19
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/dist/index.d.ts +1 -1
- package/docs/RECIPES.md +6 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1062,4 +1062,4 @@ declare const useFormAutoSubmission: <T>(form: FormWithAutoSubmit<T>, delay?: nu
|
|
|
1062
1062
|
*/
|
|
1063
1063
|
declare function useDebounce<T extends (...args: Params) => Return, Params extends unknown[] = Parameters<T>, Return = ReturnType<T>>(callback: T, delay: number): (...args: Params) => void;
|
|
1064
1064
|
|
|
1065
|
-
export { type FormValidator, type UseFormReturn, fromStandardSchema, isStandardSchema, useDebounce, useForm, useFormAutoSubmission };
|
|
1065
|
+
export { type ExtractFieldPaths, type FormValidator, type UseFormReturn, fromStandardSchema, isStandardSchema, useDebounce, useForm, useFormAutoSubmission };
|
package/docs/RECIPES.md
CHANGED
|
@@ -1195,7 +1195,7 @@ match(result, {
|
|
|
1195
1195
|
**Solution:** Extract a reusable `Field` component that takes the form instance, field name, and label.
|
|
1196
1196
|
|
|
1197
1197
|
```tsx
|
|
1198
|
-
import { useForm } from '@railway-ts/use-form';
|
|
1198
|
+
import { useForm, type UseFormReturn, type ExtractFieldPaths } from '@railway-ts/use-form';
|
|
1199
1199
|
import {
|
|
1200
1200
|
object,
|
|
1201
1201
|
required,
|
|
@@ -1214,8 +1214,8 @@ const loginSchema = object({
|
|
|
1214
1214
|
type LoginValues = InferSchemaType<typeof loginSchema>;
|
|
1215
1215
|
|
|
1216
1216
|
type FieldProps = {
|
|
1217
|
-
form:
|
|
1218
|
-
name:
|
|
1217
|
+
form: UseFormReturn<LoginValues>;
|
|
1218
|
+
name: ExtractFieldPaths<LoginValues>;
|
|
1219
1219
|
label: string;
|
|
1220
1220
|
type?: string;
|
|
1221
1221
|
};
|
|
@@ -1262,7 +1262,7 @@ Wrap field components in `React.memo` so they only re-render when their specific
|
|
|
1262
1262
|
|
|
1263
1263
|
```tsx
|
|
1264
1264
|
import { memo, useMemo } from 'react';
|
|
1265
|
-
import { useForm } from '@railway-ts/use-form';
|
|
1265
|
+
import { useForm, type UseFormReturn, type ExtractFieldPaths } from '@railway-ts/use-form';
|
|
1266
1266
|
import {
|
|
1267
1267
|
object,
|
|
1268
1268
|
required,
|
|
@@ -1283,8 +1283,8 @@ const MemoField = memo(function MemoField({
|
|
|
1283
1283
|
name,
|
|
1284
1284
|
label,
|
|
1285
1285
|
}: {
|
|
1286
|
-
form:
|
|
1287
|
-
name:
|
|
1286
|
+
form: UseFormReturn<LargeFormValues>;
|
|
1287
|
+
name: ExtractFieldPaths<LargeFormValues>;
|
|
1288
1288
|
label: string;
|
|
1289
1289
|
}) {
|
|
1290
1290
|
const props = useMemo(() => form.getFieldProps(name), [form, name]);
|
package/package.json
CHANGED