@beignet/react-hook-form 0.0.1 → 0.0.2
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/CHANGELOG.md +11 -0
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @beignet/react-hook-form
|
|
2
2
|
|
|
3
|
+
## 0.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [90b29ad]
|
|
8
|
+
- Updated dependencies [07fa19c]
|
|
9
|
+
- Updated dependencies [08bae67]
|
|
10
|
+
- Updated dependencies [730a818]
|
|
11
|
+
- Updated dependencies [a79f60c]
|
|
12
|
+
- @beignet/core@0.0.2
|
|
13
|
+
|
|
3
14
|
## 0.0.1
|
|
4
15
|
|
|
5
16
|
- Initial Beignet release under the `@beignet` npm scope.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type ContractLike, type HttpContractConfig, type InferOutput, type ResolveContract, type StandardSchemaV1 } from "@beignet/core/contracts";
|
|
2
2
|
import { type FieldValues, type UseFormProps, type UseFormReturn } from "react-hook-form";
|
|
3
3
|
/**
|
|
4
|
-
* Infer
|
|
4
|
+
* Infer React Hook Form values from a contract body schema.
|
|
5
5
|
*/
|
|
6
6
|
type InferBody<TContract extends HttpContractConfig> = TContract["body"] extends StandardSchemaV1 ? InferOutput<TContract["body"]> & FieldValues : FieldValues;
|
|
7
7
|
type FormValues<TContract extends HttpContractConfig> = InferBody<TContract>;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* React Hook Form options accepted by the Beignet adapter.
|
|
10
10
|
*/
|
|
11
11
|
type RhfFormOptions<TContract extends HttpContractConfig> = Omit<UseFormProps<FormValues<TContract>>, "resolver"> & {
|
|
12
12
|
/**
|
|
@@ -21,15 +21,15 @@ type RhfFormOptions<TContract extends HttpContractConfig> = Omit<UseFormProps<Fo
|
|
|
21
21
|
resolverEnabled?: boolean;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
|
-
* React Hook Form adapter for
|
|
24
|
+
* React Hook Form adapter for one contract.
|
|
25
25
|
*/
|
|
26
26
|
export type ReactHookFormContractAdapter<TContract extends HttpContractConfig> = {
|
|
27
27
|
/**
|
|
28
|
-
* Generate UseFormProps
|
|
28
|
+
* Generate `UseFormProps` for any React Hook Form usage.
|
|
29
29
|
*/
|
|
30
30
|
formOptions: (props?: RhfFormOptions<TContract>) => UseFormProps<FormValues<TContract>>;
|
|
31
31
|
/**
|
|
32
|
-
* Convenience wrapper around useForm(formOptions(props))
|
|
32
|
+
* Convenience wrapper around `useForm(formOptions(props))`.
|
|
33
33
|
*/
|
|
34
34
|
useForm: (props?: RhfFormOptions<TContract>) => UseFormReturn<FormValues<TContract>>;
|
|
35
35
|
};
|
|
@@ -38,6 +38,8 @@ export type ReactHookFormContractAdapter<TContract extends HttpContractConfig> =
|
|
|
38
38
|
*
|
|
39
39
|
* Mirrors the React integration pattern used by `createReactQuery()` and `createNuqs()`:
|
|
40
40
|
* create the adapter once, then bind individual contracts with `rhf(contract)`.
|
|
41
|
+
* Contracts must declare a body schema. After binding, callers may override or
|
|
42
|
+
* disable the generated resolver through `formOptions(...)` or `useForm(...)`.
|
|
41
43
|
*/
|
|
42
44
|
export declare function createReactHookForm(): <TContractLike extends ContractLike>(contract: TContractLike) => ReactHookFormContractAdapter<ResolveContract<TContractLike>>;
|
|
43
45
|
export {};
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACh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
CHANGED
|
@@ -31,6 +31,8 @@ function createReactHookFormAdapter(contract) {
|
|
|
31
31
|
*
|
|
32
32
|
* Mirrors the React integration pattern used by `createReactQuery()` and `createNuqs()`:
|
|
33
33
|
* create the adapter once, then bind individual contracts with `rhf(contract)`.
|
|
34
|
+
* Contracts must declare a body schema. After binding, callers may override or
|
|
35
|
+
* disable the generated resolver through `formOptions(...)` or `useForm(...)`.
|
|
34
36
|
*/
|
|
35
37
|
export function createReactHookForm() {
|
|
36
38
|
return function rhf(contract) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,eAAe,GAEhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAEL,OAAO,IAAI,UAAU,GAGtB,MAAM,iBAAiB,CAAC;AAoDzB,SAAS,0BAA0B,CACjC,QAAuB;IAEvB,MAAM,gBAAgB,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAEnD,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CACb,OAAO,gBAAgB,CAAC,IAAI,kCAAkC;YAC5D,iFAAiF;YACjF,6EAA6E,CAChF,CAAC;IACJ,CAAC;IAID,SAAS,WAAW,CAClB,KAAsD;QAEtD,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAGvB,CAAC;QAEd,MAAM,EACJ,eAAe,GAAG,IAAI,EACtB,QAAQ,EAAE,gBAAgB,EAC1B,GAAG,IAAI,EACR,GAAG,KAAK,IAAI,EAAE,CAAC;QAEhB,MAAM,QAAQ,GACZ,gBAAgB;YAChB,CAAC,UAAU,IAAI,eAAe;gBAC5B,CAAC,CAAC,sBAAsB,CAAC,UAAU,CAAC;gBACpC,CAAC,CAAC,SAAS,CAAC,CAAC;QAEjB,OAAO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,WAAW,CAAC,KAAK,CAAC,CAAC;QACnC,OAAO,UAAU,CAAS,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;AAClC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,SAAS,GAAG,CACjB,QAAuB;QAEvB,OAAO,0BAA0B,CAAC,QAAQ,CAAC,CAAC;IAC9C,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "react-hook-form";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* Infer
|
|
18
|
+
* Infer React Hook Form values from a contract body schema.
|
|
19
19
|
*/
|
|
20
20
|
type InferBody<TContract extends HttpContractConfig> =
|
|
21
21
|
TContract["body"] extends StandardSchemaV1
|
|
@@ -25,7 +25,7 @@ type InferBody<TContract extends HttpContractConfig> =
|
|
|
25
25
|
type FormValues<TContract extends HttpContractConfig> = InferBody<TContract>;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* React Hook Form options accepted by the Beignet adapter.
|
|
29
29
|
*/
|
|
30
30
|
type RhfFormOptions<TContract extends HttpContractConfig> = Omit<
|
|
31
31
|
UseFormProps<FormValues<TContract>>,
|
|
@@ -45,19 +45,19 @@ type RhfFormOptions<TContract extends HttpContractConfig> = Omit<
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* React Hook Form adapter for
|
|
48
|
+
* React Hook Form adapter for one contract.
|
|
49
49
|
*/
|
|
50
50
|
export type ReactHookFormContractAdapter<TContract extends HttpContractConfig> =
|
|
51
51
|
{
|
|
52
52
|
/**
|
|
53
|
-
* Generate UseFormProps
|
|
53
|
+
* Generate `UseFormProps` for any React Hook Form usage.
|
|
54
54
|
*/
|
|
55
55
|
formOptions: (
|
|
56
56
|
props?: RhfFormOptions<TContract>,
|
|
57
57
|
) => UseFormProps<FormValues<TContract>>;
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* Convenience wrapper around useForm(formOptions(props))
|
|
60
|
+
* Convenience wrapper around `useForm(formOptions(props))`.
|
|
61
61
|
*/
|
|
62
62
|
useForm: (
|
|
63
63
|
props?: RhfFormOptions<TContract>,
|
|
@@ -120,6 +120,8 @@ function createReactHookFormAdapter<TContractLike extends ContractLike>(
|
|
|
120
120
|
*
|
|
121
121
|
* Mirrors the React integration pattern used by `createReactQuery()` and `createNuqs()`:
|
|
122
122
|
* create the adapter once, then bind individual contracts with `rhf(contract)`.
|
|
123
|
+
* Contracts must declare a body schema. After binding, callers may override or
|
|
124
|
+
* disable the generated resolver through `formOptions(...)` or `useForm(...)`.
|
|
123
125
|
*/
|
|
124
126
|
export function createReactHookForm() {
|
|
125
127
|
return function rhf<TContractLike extends ContractLike>(
|