@simoncomputing/mui-bueno-v3 0.1.18 → 0.2.1
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.md +1 -1
- package/dist/components/Form/MForm/MForm2.d.ts +1 -1
- package/dist/components/Form/MForm/MFormProvider2.d.ts +17 -6
- package/dist/index.cjs.js +92 -92
- package/dist/index.es.js +4103 -4083
- package/dist/index.umd.js +91 -91
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ In the application repo:
|
|
|
41
41
|
|
|
42
42
|
```shell
|
|
43
43
|
# Update package to look for this file in the proper directory.
|
|
44
|
-
npm i ~/git/mui-bueno-v3/simoncomputing-mui-bueno-v3-0.1.
|
|
44
|
+
npm i ~/git/mui-bueno-v3/simoncomputing-mui-bueno-v3-0.2.1.tgz
|
|
45
45
|
|
|
46
46
|
# Install
|
|
47
47
|
npm install
|
|
@@ -54,7 +54,7 @@ import * as React from 'react';
|
|
|
54
54
|
*
|
|
55
55
|
* **Owned mode**
|
|
56
56
|
* - pass `defaultValues: DefaultValues<T>` (required)
|
|
57
|
-
* - optionally pass `resolver`, `useFormProps`, `reinitializeKey`, etc.
|
|
57
|
+
* - optionally pass `validationSchema` (Yup) and/or `resolver`, `useFormProps`, `reinitializeKey`, etc.
|
|
58
58
|
*
|
|
59
59
|
* ## Default values (source of truth)
|
|
60
60
|
* MForm2 does not define its own default values. It forwards props to `MFormProvider2`, which chooses:
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DefaultValues, FieldValues, Resolver, SubmitErrorHandler, SubmitHandler, UseFormProps, UseFormReturn } from 'react-hook-form';
|
|
2
|
+
import { AnyObjectSchema } from 'yup';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
/**
|
|
4
5
|
* # MFormProvider2 Documentation
|
|
@@ -9,7 +10,7 @@ import * as React from 'react';
|
|
|
9
10
|
* - Standardizes submit behavior (including optional Axios 422 → field error mapping).
|
|
10
11
|
* - Supports two modes:
|
|
11
12
|
* - **Controlled**: you create the RHF methods with `useForm()` elsewhere and pass `methods`.
|
|
12
|
-
* - **Owned**: this provider calls `useForm()` internally using `defaultValues
|
|
13
|
+
* - **Owned**: this provider calls `useForm()` internally using `defaultValues`/resolver.
|
|
13
14
|
* - Optionally exposes a programmatic submit function via:
|
|
14
15
|
* - `submitRef` (imperative ref),
|
|
15
16
|
* - and/or an internal context + `useMForm2()` hook.
|
|
@@ -47,15 +48,16 @@ import * as React from 'react';
|
|
|
47
48
|
* - You need `methods` in the parent component (e.g., `useFieldArray()` at the dialog level),
|
|
48
49
|
* - You want to configure RHF outside of the wrapper.
|
|
49
50
|
*
|
|
51
|
+
* Note: in controlled mode, `validationSchema` is not accepted because the resolver must be configured
|
|
52
|
+
* when you create `methods` via `useForm({ resolver: ... })`.
|
|
53
|
+
*
|
|
50
54
|
* ### Owned mode
|
|
51
|
-
* You provide `defaultValues` (and optionally `resolver`, `useFormProps`, etc.):
|
|
55
|
+
* You provide `defaultValues` (and optionally `validationSchema`, `resolver`, `useFormProps`, etc.):
|
|
52
56
|
* ```ts
|
|
53
|
-
* <MFormProvider2 defaultValues={...}
|
|
57
|
+
* <MFormProvider2 defaultValues={...} validationSchema={...} onSubmit={...}>{...}</MFormProvider2>
|
|
54
58
|
* ```
|
|
55
59
|
*
|
|
56
|
-
*
|
|
57
|
-
* - You want a very simple call site,
|
|
58
|
-
* - You don’t need to share methods with a parent component.
|
|
60
|
+
* Owned mode is the recommended path when you want minimal call-site configuration.
|
|
59
61
|
*
|
|
60
62
|
* ## Error mapping (Axios 422 → RHF errors)
|
|
61
63
|
*
|
|
@@ -203,6 +205,15 @@ export type MFormProvider2ControlledProps<T extends FieldValues> = CommonProps<T
|
|
|
203
205
|
*/
|
|
204
206
|
export type MFormProvider2OwnedProps<T extends FieldValues> = CommonProps<T> & {
|
|
205
207
|
defaultValues: DefaultValues<T>;
|
|
208
|
+
/**
|
|
209
|
+
* Yup schema for validation (owned mode convenience).
|
|
210
|
+
* If provided and `resolver` is not provided, the provider will use `yupResolver(validationSchema)`.
|
|
211
|
+
*/
|
|
212
|
+
validationSchema?: AnyObjectSchema;
|
|
213
|
+
/**
|
|
214
|
+
* Explicit resolver override.
|
|
215
|
+
* If provided, it takes precedence over `validationSchema`.
|
|
216
|
+
*/
|
|
206
217
|
resolver?: Resolver<T>;
|
|
207
218
|
shouldFocusError?: boolean;
|
|
208
219
|
useFormProps?: Omit<UseFormProps<T>, 'defaultValues' | 'resolver' | 'shouldFocusError'>;
|