@simoncomputing/mui-bueno-v3 0.1.14 → 0.1.16

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,77 @@ 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.16.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
+ This project has been updated to require MFA and reject access tokens.
63
+
64
+ 1. remove `~/.npmrc` if it exists. We will login using MFA through the browser.
65
+ 1. At command line, type: `npm login`
66
+ 1. You'll be prompted to press enter to open the browser.
67
+ 1. Finish your login process.
68
+ 1. You can now confirm you're logged in:
69
+
70
+ ```shell
71
+ # This should identify your user ID
72
+ npm whoami
73
+
74
+ # Logout
75
+ npm logout
76
+
77
+ # Running whoami again should return an error
78
+ npm whoami
79
+
80
+ # Log back in
81
+ npm login
82
+ ```
83
+
84
+ #### Run the build
85
+
86
+ Go into `package.json` and set `private` to `false`. Don't check this in as this is safety against accidental deployment.
87
+
88
+ ```shell
89
+ # Test with dry run
90
+ npm run publishLib:dryrun
91
+
92
+ # Run actual deployment
93
+ npm run publishLib
94
+ ```
95
+
96
+ Undo your change to `package.json`
97
+
27
98
  ## Documentation & Demo
28
99
 
29
100
  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 {};