remix-validated-form 3.3.0 → 3.3.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.
@@ -1,9 +1,9 @@
1
1
  $ npm run build:browser && npm run build:main
2
2
 
3
- > remix-validated-form@3.2.2 build:browser
3
+ > remix-validated-form@3.3.0 build:browser
4
4
  > tsc --module ESNext --outDir ./browser
5
5
 
6
6
 
7
- > remix-validated-form@3.2.2 build:main
7
+ > remix-validated-form@3.3.0 build:main
8
8
  > tsc --module CommonJS --outDir ./build
9
9
 
package/README.md CHANGED
@@ -63,7 +63,7 @@ type MyInputProps = {
63
63
  label: string;
64
64
  };
65
65
 
66
- export const MyInput = ({ name, label }: InputProps) => {
66
+ export const MyInput = ({ name, label }: MyInputProps) => {
67
67
  const { error, getInputProps } = useField(name);
68
68
  return (
69
69
  <div>
@@ -257,4 +257,4 @@ See the [Remix](https://remix.run/docs/en/v1/api/remix#sessionflashkey-value) do
257
257
 
258
258
  ## Why is my cancel button triggering form submission?
259
259
  Problem: the cancel button has an onClick handler to navigate away from the form route but instead it is submitting the form.
260
- A button defaults to `type="submit"` in a form which will submit the form by default. If you want to prevent this you can add `type="reset"` or `type="button"` to the cancel button.
260
+ A button defaults to `type="submit"` in a form which will submit the form by default. If you want to prevent this you can add `type="reset"` or `type="button"` to the cancel button.
@@ -14,8 +14,10 @@ export declare type CreateGetInputPropsOptions = {
14
14
  validationBehavior?: Partial<ValidationBehaviorOptions>;
15
15
  name: string;
16
16
  };
17
- declare type HandledProps = "name" | "defaultValue";
18
- declare type Callbacks = "onChange" | "onBlur";
19
- export declare type GetInputProps = <T extends Record<string, any>>(props?: Omit<T, HandledProps | Callbacks> & Partial<Pick<T, Callbacks>>) => T;
17
+ declare type OmitHandledProps = {
18
+ name?: never;
19
+ defaultValue?: never;
20
+ };
21
+ export declare type GetInputProps = <T extends Record<string, any>>(props?: T & OmitHandledProps) => T;
20
22
  export declare const createGetInputProps: ({ clearError, validate, defaultValue, touched, setTouched, hasBeenSubmitted, validationBehavior, name, }: CreateGetInputPropsOptions) => GetInputProps;
21
23
  export {};
File without changes
File without changes
@@ -0,0 +1 @@
1
+ export declare const useMultiValueMap: <Key, Value>() => () => any;
@@ -0,0 +1,11 @@
1
+ import { MultiValueMap } from "multi-value-map";
2
+ import { useRef } from "react";
3
+ export const useMultiValueMap = () => {
4
+ const ref = useRef(null);
5
+ return () => {
6
+ if (ref.current)
7
+ return ref.current;
8
+ ref.current = new MultiValueMap();
9
+ return ref.current;
10
+ };
11
+ };
File without changes
File without changes
@@ -14,8 +14,10 @@ export declare type CreateGetInputPropsOptions = {
14
14
  validationBehavior?: Partial<ValidationBehaviorOptions>;
15
15
  name: string;
16
16
  };
17
- declare type HandledProps = "name" | "defaultValue";
18
- declare type Callbacks = "onChange" | "onBlur";
19
- export declare type GetInputProps = <T extends Record<string, any>>(props?: Omit<T, HandledProps | Callbacks> & Partial<Pick<T, Callbacks>>) => T;
17
+ declare type OmitHandledProps = {
18
+ name?: never;
19
+ defaultValue?: never;
20
+ };
21
+ export declare type GetInputProps = <T extends Record<string, any>>(props?: T & OmitHandledProps) => T;
20
22
  export declare const createGetInputProps: ({ clearError, validate, defaultValue, touched, setTouched, hasBeenSubmitted, validationBehavior, name, }: CreateGetInputPropsOptions) => GetInputProps;
21
23
  export {};
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remix-validated-form",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "description": "Form component and utils for easy form validation in remix",
5
5
  "browser": "./browser/index.js",
6
6
  "main": "./build/index.js",
@@ -17,11 +17,12 @@ export type CreateGetInputPropsOptions = {
17
17
  name: string;
18
18
  };
19
19
 
20
- type HandledProps = "name" | "defaultValue";
21
- type Callbacks = "onChange" | "onBlur";
20
+ // Using Omit<T, HandledProps> breaks type inference sometimes for some reason.
21
+ // Doing T & OmitHandledProps gives us the same behavior without breaking type inference.
22
+ type OmitHandledProps = { name?: never; defaultValue?: never };
22
23
 
23
24
  export type GetInputProps = <T extends Record<string, any>>(
24
- props?: Omit<T, HandledProps | Callbacks> & Partial<Pick<T, Callbacks>>
25
+ props?: T & OmitHandledProps
25
26
  ) => T;
26
27
 
27
28
  const defaultValidationBehavior: ValidationBehaviorOptions = {