remix-validated-form 3.1.0 → 3.1.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.0.0 build:browser
3
+ > remix-validated-form@3.1.0 build:browser
4
4
  > tsc --module ESNext --outDir ./browser
5
5
 
6
6
 
7
- > remix-validated-form@3.0.0 build:main
7
+ > remix-validated-form@3.1.0 build:main
8
8
  > tsc --module CommonJS --outDir ./build
9
9
 
package/README.md CHANGED
@@ -10,6 +10,10 @@ A form library built for [remix](https://remix.run) to make validation easy.
10
10
  - Supports nested objects and arrays
11
11
  - Validation library agnostic
12
12
 
13
+ # Docs
14
+
15
+ The docs are located a [remix-validated-form.io](https://www.remix-validated-form.io).
16
+
13
17
  # Demo
14
18
 
15
19
  https://user-images.githubusercontent.com/2811287/145734901-700a5085-a10b-4d89-88e1-5de9142b1e85.mov
@@ -82,18 +86,22 @@ export const MyInput = ({ name, label }: InputProps) => {
82
86
  To best take advantage of the per-form submission detection, we can create a submit button component.
83
87
 
84
88
  ```tsx
85
- import { useIsSubmitting } from "remix-validated-form";
89
+ import { useFormContext, useIsSubmitting } from "remix-validated-form";
86
90
 
87
91
  export const MySubmitButton = () => {
88
92
  const isSubmitting = useIsSubmitting();
93
+ const { isValid } = useFormContext();
94
+ const disabled = isSubmitting || !isValid;
95
+
89
96
  return (
90
- <button type="submit" disabled={isSubmitting}>
97
+ <button type="submit" disabled={disabled} className={disabled ? "disabled-btn" : "btn"}>
91
98
  {isSubmitting ? "Submitting..." : "Submit"}
92
99
  </button>
93
100
  );
94
101
  };
95
102
  ```
96
103
 
104
+
97
105
  ## Use the form!
98
106
 
99
107
  Now that we have our components, making a form is easy!
@@ -245,3 +253,8 @@ This is happening because you or the library you are using is passing the `requi
245
253
  This library doesn't take care of eliminating them and it's up to the user how they want to manage the validation errors.
246
254
  If you wan't to disable all native HTML validations you can add `noValidate` to `<ValidatedForm>`.
247
255
  We recommend this approach since the validation will still work even if JS is disabled.
256
+
257
+ ## How do we trigger toast messages on success?
258
+
259
+ Problem: how do we trigger a toast message on success if the action redirects away from the form route? The Remix solution is to flash a message in the session and pick this up in a loader function, probably in root.tsx
260
+ See the [Remix](https://remix.run/docs/en/v1/api/remix#sessionflashkey-value) documentation for more information.
File without changes
File without changes
File without changes
File without changes
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.1.0",
3
+ "version": "3.1.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",