@paragrav/rhf-utils 0.0.57 → 0.0.59

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,14 +1,21 @@
1
- let o;
2
- const n = (t) => {
3
- o = t;
4
- }, e = (t) => ({
5
- ...o,
6
- options: {
7
- ...o == null ? void 0 : o.options,
8
- ...t
9
- }
10
- });
1
+ let s;
2
+ const t = (e) => {
3
+ s = e;
4
+ }, l = (e) => {
5
+ var a;
6
+ return {
7
+ ...s,
8
+ options: {
9
+ ...s == null ? void 0 : s.options,
10
+ ...e,
11
+ classNames: [
12
+ ...((a = s == null ? void 0 : s.options) == null ? void 0 : a.classNames) ?? [],
13
+ ...(e == null ? void 0 : e.classNames) ?? []
14
+ ]
15
+ }
16
+ };
17
+ };
11
18
  export {
12
- e as _getConfig,
13
- n as setConfig
19
+ l as _getConfig,
20
+ t as setConfig
14
21
  };
@@ -1,6 +1,7 @@
1
1
  import { FormSubmitError } from '../submit/error/FormSubmitError';
2
2
  import { UseFormFieldsProps, UseFormOptions } from '../form/useForm';
3
- import { FieldValues, UseFormProps, UseFormStateReturn } from 'react-hook-form';
3
+ import { _FormSlots } from '../form/_Form';
4
+ import { UseFormProps } from 'react-hook-form';
4
5
 
5
6
  type Config = {
6
7
  rhf?: Pick<UseFormProps, 'mode' | 'reValidateMode' | 'resetOptions' | 'context' | 'shouldFocusError' | 'shouldUnregister' | 'shouldUseNativeValidation' | 'progressive' | 'criteriaMode' | 'delayError'>;
@@ -11,21 +12,21 @@ type Config = {
11
12
  */
12
13
  options?: UseFormOptions;
13
14
  /**
14
- * Component injected at the top of the form.
15
+ * Components injected by slot.
15
16
  *
16
- * e.g., block navigation on dirty form.
17
+ * e.g., top: block navigation on dirty form.
18
+ * e.g., bottom: root errors list.
17
19
  */
18
- Children?: React.FC<UseFormFieldsProps>;
20
+ Children?: Partial<Record<_FormSlots, React.FC<UseFormFieldsProps>>>;
19
21
  /**
20
22
  * Handle non-{@link FormSubmitError} errors. Optionally, return {@link FormSubmitError} to merge into context errors.
21
23
  */
22
24
  onSubmitError?: (error: unknown) => FormSubmitError | undefined;
23
- Prompter?: React.FC<UseFormStateReturn<FieldValues>>;
24
25
  };
25
26
  export declare const setConfig: (config: Config) => void;
26
27
  export declare const _getConfig: (options?: UseFormOptions) => {
27
28
  options: {
28
- hideRootErrorsList?: boolean | undefined;
29
+ classNames: string[];
29
30
  submitOnChange?: boolean | undefined;
30
31
  resetValuesOnSubmitError?: boolean | undefined;
31
32
  stopSubmitPropagation?: boolean | undefined;
@@ -37,9 +38,9 @@ export declare const _getConfig: (options?: UseFormOptions) => {
37
38
  reValidateMode: "onBlur" | "onChange" | "onSubmit";
38
39
  defaultValues: {
39
40
  [x: string]: any;
40
- } | ((payload?: unknown) => Promise<FieldValues>);
41
- values: FieldValues;
42
- errors: import('react-hook-form').FieldErrors<FieldValues>;
41
+ } | ((payload?: unknown) => Promise<import('react-hook-form').FieldValues>);
42
+ values: import('react-hook-form').FieldValues;
43
+ errors: import('react-hook-form').FieldErrors<import('react-hook-form').FieldValues>;
43
44
  resetOptions: Partial<{
44
45
  keepDirtyValues: boolean;
45
46
  keepErrors: boolean;
@@ -53,7 +54,7 @@ export declare const _getConfig: (options?: UseFormOptions) => {
53
54
  keepIsValid: boolean;
54
55
  keepSubmitCount: boolean;
55
56
  }> | undefined;
56
- resolver: import('react-hook-form').Resolver<FieldValues, any>;
57
+ resolver: import('react-hook-form').Resolver<import('react-hook-form').FieldValues, any>;
57
58
  context: any;
58
59
  shouldFocusError: boolean;
59
60
  shouldUnregister: boolean;
@@ -62,8 +63,7 @@ export declare const _getConfig: (options?: UseFormOptions) => {
62
63
  criteriaMode: import('react-hook-form').CriteriaMode;
63
64
  delayError: number;
64
65
  }>, "mode" | "reValidateMode" | "resetOptions" | "context" | "shouldFocusError" | "shouldUnregister" | "shouldUseNativeValidation" | "progressive" | "criteriaMode" | "delayError"> | undefined;
65
- Children?: import('react').FC<UseFormFieldsProps> | undefined;
66
+ Children?: Partial<Record<_FormSlots, import('react').FC<UseFormFieldsProps>>> | undefined;
66
67
  onSubmitError?: ((error: unknown) => FormSubmitError | undefined) | undefined;
67
- Prompter?: import('react').FC<UseFormStateReturn<FieldValues>> | undefined;
68
68
  };
69
69
  export {};
@@ -3,6 +3,7 @@ import { z } from 'zod';
3
3
  import { FieldValues } from 'react-hook-form';
4
4
  import { default as React } from 'react';
5
5
 
6
+ export type _FormSlots = 'top' | 'bottom';
6
7
  export type _FormProps<TSchema extends z.ZodObject<FieldValues>, TFieldValues extends z.input<TSchema>, TTransformedValues extends z.output<TSchema>> = React.PropsWithChildren<Pick<UseFormProps<TSchema, TFieldValues, TTransformedValues>, 'form'> & {
7
8
  formId: string;
8
9
  formRef: React.RefObject<HTMLFormElement>;
@@ -7,12 +7,15 @@ import { default as React } from 'react';
7
7
  import { DevtoolUIProps } from '@hookform/devtools/dist/devToolUI';
8
8
 
9
9
  export type UseFormOptions = {
10
- hideRootErrorsList?: boolean;
10
+ /** Control visibility of certain items via your own classes and styles. */
11
+ classNames?: string[];
11
12
  /** Request submit via listener on form change. */
12
13
  submitOnChange?: boolean;
13
14
  /** Reset form values if submit throw errors. Use case: optimistic UI toggle form that submits on each change */
14
15
  resetValuesOnSubmitError?: boolean;
16
+ /** Stop propagation of submit event. Useful for portals. */
15
17
  stopSubmitPropagation?: boolean;
18
+ /** Control dev tool options. */
16
19
  devTool?: DevtoolUIProps | 'disabled';
17
20
  };
18
21
  export type UseFormFieldsProps<TFieldValues extends FieldValues = FieldValues, TTransformedValues extends FieldValues = FieldValues> = {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@paragrav/rhf-utils",
3
3
  "author": "paragrav.dev",
4
4
  "license": "MIT",
5
- "version": "0.0.57",
5
+ "version": "0.0.59",
6
6
  "description": "Integration utilities for react-hook-form.",
7
7
  "type": "module",
8
8
  "sideEffects": false,