@powerhousedao/design-system 1.39.15-dev.3 → 1.39.15-dev.4
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type UseFormReturn } from "react-hook-form";
|
|
1
|
+
import { type UseFormProps, type UseFormReturn } from "react-hook-form";
|
|
2
2
|
type FormMethods = UseFormReturn & {
|
|
3
3
|
/**
|
|
4
4
|
* Trigger the form submit event
|
|
@@ -50,6 +50,12 @@ interface FormProps {
|
|
|
50
50
|
* @default false The errors will be rendered automatically on top of the form.
|
|
51
51
|
*/
|
|
52
52
|
renderSubmitErrorsManually?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Additional props to pass to the form config from react-hook-form.
|
|
55
|
+
*
|
|
56
|
+
* Note: this could affect the form behavior, use with caution.
|
|
57
|
+
*/
|
|
58
|
+
extraFormProps?: UseFormProps;
|
|
53
59
|
/**
|
|
54
60
|
* Callback to match a submission error with one or more form fields or form level errors.
|
|
55
61
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../../../src/scalars/components/form/form.tsx"],"names":[],"mappings":"AAQA,OAAO,
|
|
1
|
+
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../../../src/scalars/components/form/form.tsx"],"names":[],"mappings":"AAQA,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,aAAa,EACnB,MAAM,iBAAiB,CAAC;AAIzB,KAAK,WAAW,GAAG,aAAa,GAAG;IACjC;;OAEG;IACH,aAAa,EAAE,MAAM,IAAI,CAAC;IAE1B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,UAAU,SAAS;IACjB;;;;OAIG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,OAAO,EAAE,WAAW,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAExE;;;;;OAKG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9C;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEpC;;;;;OAKG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;IAErC;;;;OAIG;IACH,cAAc,CAAC,EAAE,YAAY,CAAC;IAE9B;;;;;;;;;;OAUG;IACH,sBAAsB,CAAC,EAAE,CACvB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,MAAM,EAAE,KACjB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE5B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,IAAI,qGAuJhB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { castValue, deepEqual, isEmpty } from "#scalars";
|
|
3
3
|
import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, } from "react";
|
|
4
|
-
import { FormProvider, useForm } from "react-hook-form";
|
|
4
|
+
import { FormProvider, useForm, } from "react-hook-form";
|
|
5
5
|
import { FormServerErrorMessage } from "../fragments/form-message/form-server-error-message.js";
|
|
6
6
|
import { defaultOnError } from "./utils.js";
|
|
7
7
|
/**
|
|
@@ -38,11 +38,12 @@ import { defaultOnError } from "./utils.js";
|
|
|
38
38
|
* </Form>
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
-
export const Form = forwardRef(({ children, onSubmit, resetOnSuccessfulSubmit = false, submitChangesOnly = false, defaultValues, renderSubmitErrorsManually = false, submissionErrorMatcher = defaultOnError, className, }, ref) => {
|
|
41
|
+
export const Form = forwardRef(({ children, onSubmit, resetOnSuccessfulSubmit = false, submitChangesOnly = false, defaultValues, renderSubmitErrorsManually = false, submissionErrorMatcher = defaultOnError, className, extraFormProps, }, ref) => {
|
|
42
42
|
const formId = useId();
|
|
43
43
|
const methods = useForm({
|
|
44
44
|
defaultValues,
|
|
45
45
|
criteriaMode: "all", // display all errors at once
|
|
46
|
+
...extraFormProps,
|
|
46
47
|
});
|
|
47
48
|
useImperativeHandle(ref, () => methods, [methods]);
|
|
48
49
|
useEffect(() => {
|