@simoncomputing/mui-bueno-v3 0.1.14 → 0.1.15

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 CHANGED
@@ -24,6 +24,75 @@ npm install mui-bueno-v3
24
24
  </MForm>
25
25
  ```
26
26
 
27
+ ## Running the Library Locally
28
+
29
+ To test locally before submitting to NPM, perform the following:
30
+
31
+ ```shell
32
+
33
+ rm -rf dist
34
+ npm run build:lib
35
+ npm pack
36
+
37
+ # will output something like: simoncomputing-mui-bueno-v3-0.1.14.tgz
38
+ ```
39
+
40
+ In the application repo:
41
+
42
+ ```shell
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.15.tgz
45
+
46
+ # Install
47
+ npm install
48
+
49
+ ## If you want a clean reinstall
50
+ rm -rf node_modules package-lock.json
51
+ npm install
52
+ ```
53
+
54
+ ## Deploying to NPM
55
+
56
+ #### Get an NPM Account
57
+
58
+ 1. Request an account from Simon, indicate you want to deploy mui-bueno-v3.
59
+
60
+ #### Log into NPM
61
+
62
+ 1. At command line, type: `npm login`
63
+ 1. You'll be prompted to press enter to open the browser.
64
+ 1. Finish your login process.
65
+ 1. You can now confirm you're logged in:
66
+
67
+ ```shell
68
+
69
+ # This should identify your user ID
70
+ npm whoami
71
+
72
+ # Logout
73
+ npm logout
74
+
75
+ # Running whoami again should return an error
76
+ npm whoami
77
+
78
+ # Log back in
79
+ npm login
80
+ ```
81
+
82
+ #### Run the build
83
+
84
+ Go into `package.json` and set `private` to `false`. Don't check this in as this is safety against accidental deployment.
85
+
86
+ ```shell
87
+ # Test with dry run
88
+ npm run publishLib:dryrun
89
+
90
+ # Run actual deployment
91
+ npm run publishLib
92
+ ```
93
+
94
+ Undo your change to `package.json`
95
+
27
96
  ## Documentation & Demo
28
97
 
29
98
  This project uses Storybook to document and demonstrate the components. _URL COMING SOON._
@@ -190,3 +190,5 @@ export type UnsavedCitation = {
190
190
  export type UnsavedAttachment = {
191
191
  file?: File;
192
192
  } & UnsavedCitation;
193
+
194
+ export type StoryFormValues = Record<string, any>;
@@ -1,19 +1,24 @@
1
+ import { default as React } from 'react';
1
2
  import { SubmitHandler, FieldValues, DefaultValues, FieldErrors, UseFormSetValue, UseFormReturn } from 'react-hook-form';
2
3
  import { AnyObjectSchema } from 'yup';
4
+ type MFormChildProps<T extends FieldValues> = {
5
+ values: T;
6
+ setValue: UseFormSetValue<T>;
7
+ methods: UseFormReturn<T>;
8
+ };
3
9
  type MFormProps<T extends FieldValues> = Readonly<{
4
10
  initialValues: DefaultValues<T>;
5
11
  initialErrors?: FieldErrors<T>;
6
- onSubmit: SubmitHandler<T>;
7
- children: React.ReactNode | ((props: {
8
- values: T;
9
- setValue: UseFormSetValue<T>;
10
- methods: UseFormReturn<T>;
11
- }) => React.ReactNode);
12
+ onSubmit: SubmitHandler<T> | ((values: T) => Promise<void>);
13
+ children: React.ReactNode | ((props: MFormChildProps<T>) => React.ReactNode);
12
14
  validationSchema?: AnyObjectSchema;
13
15
  shouldValidateOption?: boolean;
14
16
  shouldDirtyOption?: boolean;
15
17
  validationOnMount?: boolean;
16
18
  enableReinitialize?: boolean;
19
+ /** Automatically catch and apply 422 server errors (Axios-style). */
20
+ applyAxios422Errors?: boolean;
21
+ submitRef?: React.RefObject<(() => Promise<void>) | null>;
17
22
  }>;
18
- export declare function MForm<T extends FieldValues>({ initialValues, onSubmit, children, initialErrors, validationSchema, shouldValidateOption, shouldDirtyOption, validationOnMount, enableReinitialize }: MFormProps<T>): import("react/jsx-runtime").JSX.Element;
23
+ export declare function MForm<T extends FieldValues>({ initialValues, onSubmit, children, initialErrors, validationSchema, shouldValidateOption, shouldDirtyOption, validationOnMount, enableReinitialize, applyAxios422Errors, submitRef, }: MFormProps<T>): import("react/jsx-runtime").JSX.Element;
19
24
  export default MForm;
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ export type ServerErrorMap = Record<string, string>;
3
+ type MFormCtx = {
4
+ applyServerErrors: (errors: ServerErrorMap, focusFirst?: boolean) => void;
5
+ };
6
+ export declare const MFormContext: React.Context<MFormCtx | null>;
7
+ export declare function useMForm(): MFormCtx;
8
+ export {};