@simoncomputing/mui-bueno-v3 0.1.12
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/CHANGELOG.md +45 -0
- package/README.md +33 -0
- package/dist/@types/index.d.ts +192 -0
- package/dist/common/TestUtils/reactHookForms.d.ts +54 -0
- package/dist/common/TestUtils/renderWithReactHookForm.d.ts +7 -0
- package/dist/common/Utils/index.d.ts +65 -0
- package/dist/common/WindowDimensions/WindowDimensions.d.ts +26 -0
- package/dist/components/Alerts/Alert.d.ts +30 -0
- package/dist/components/Alerts/ErrorAlert.d.ts +4 -0
- package/dist/components/Alerts/InfoAlert.d.ts +4 -0
- package/dist/components/Alerts/SuccessAlert.d.ts +4 -0
- package/dist/components/Alerts/WarningAlert.d.ts +4 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +10 -0
- package/dist/components/Buttons/Button/Button.d.ts +24 -0
- package/dist/components/Buttons/ScrollToTop/ScrollToTop.d.ts +14 -0
- package/dist/components/Buttons/Submit/Submit.d.ts +11 -0
- package/dist/components/Form/Error/Error.d.ts +23 -0
- package/dist/components/Form/FormDebugger/FormDebugger.d.ts +8 -0
- package/dist/components/Form/Inputs/Autocomplete/Autocomplete.d.ts +81 -0
- package/dist/components/Form/Inputs/Autocomplete/DynamicAutocomplete/DynamicAutocomplete.d.ts +31 -0
- package/dist/components/Form/Inputs/Autocomplete/MultiAutocomplete/MultiAutocomplete.d.ts +22 -0
- package/dist/components/Form/Inputs/Autocomplete/utils.d.ts +2 -0
- package/dist/components/Form/Inputs/Checkbox/Checkbox.d.ts +58 -0
- package/dist/components/Form/Inputs/CheckboxGroup/CheckboxGroup.d.ts +112 -0
- package/dist/components/Form/Inputs/CitationField/CitationBubbleMenuHandler.d.ts +43 -0
- package/dist/components/Form/Inputs/CitationField/CitationField.d.ts +78 -0
- package/dist/components/Form/Inputs/CitationField/CitationMenu/AttachmentForm.d.ts +13 -0
- package/dist/components/Form/Inputs/CitationField/CitationMenu/CitationBubbleMenu.d.ts +25 -0
- package/dist/components/Form/Inputs/CitationField/CitationMenu/CitationForm.d.ts +12 -0
- package/dist/components/Form/Inputs/CitationField/CitationMenu/CitationMenu.d.ts +62 -0
- package/dist/components/Form/Inputs/CitationField/CitationMenu/CitationTable.d.ts +16 -0
- package/dist/components/Form/Inputs/CitationField/CitationNode.d.ts +2 -0
- package/dist/components/Form/Inputs/CitationField/CitationNodeComponent.d.ts +7 -0
- package/dist/components/Form/Inputs/CitationField/CitationRefreshContext/CitationRefreshContext.d.ts +29 -0
- package/dist/components/Form/Inputs/CitationField/MenuButtonEditCitation.d.ts +3 -0
- package/dist/components/Form/Inputs/DateField/DateField.d.ts +73 -0
- package/dist/components/Form/Inputs/DateField/DateRangeField/DateRangeField.d.ts +62 -0
- package/dist/components/Form/Inputs/DateField/dayjs-utils.d.ts +2 -0
- package/dist/components/Form/Inputs/FileUpload/FileList/FileList.d.ts +13 -0
- package/dist/components/Form/Inputs/FileUpload/FileUpload.d.ts +62 -0
- package/dist/components/Form/Inputs/Location/Location.d.ts +69 -0
- package/dist/components/Form/Inputs/Location/Location.types.d.ts +85 -0
- package/dist/components/Form/Inputs/Location/LocationOption.d.ts +38 -0
- package/dist/components/Form/Inputs/RadioGroup/RadioGroup.d.ts +119 -0
- package/dist/components/Form/Inputs/RangeSlider/RangeSlider.d.ts +34 -0
- package/dist/components/Form/Inputs/RichTextField/RichTextControls.d.ts +6 -0
- package/dist/components/Form/Inputs/RichTextField/RichTextField.d.ts +56 -0
- package/dist/components/Form/Inputs/RichTextField/SuggestionList.d.ts +8 -0
- package/dist/components/Form/Inputs/RichTextField/mentionSuggestionOptions.d.ts +6 -0
- package/dist/components/Form/Inputs/RichTextField/useExtensions.d.ts +10 -0
- package/dist/components/Form/Inputs/SearchField/SearchField.d.ts +16 -0
- package/dist/components/Form/Inputs/Select/Select.d.ts +91 -0
- package/dist/components/Form/Inputs/Switch/Switch.d.ts +61 -0
- package/dist/components/Form/Inputs/TextField/TextField.d.ts +60 -0
- package/dist/components/Form/MForm/MForm.d.ts +19 -0
- package/dist/components/Form/MForm/useMyForm.d.ts +1 -0
- package/dist/components/Form/RepeatableFormGroup/RepeatableFormGroup.d.ts +89 -0
- package/dist/components/Form/Stepper/Stepper.d.ts +27 -0
- package/dist/components/Layout/MGrid/MGrid.d.ts +13 -0
- package/dist/components/Layout/MPanel/MPanel.d.ts +13 -0
- package/dist/components/Layout/MStack/MStack.d.ts +6 -0
- package/dist/components/LoadingIndicator/LoadingIndicator.d.ts +22 -0
- package/dist/components/Modals/AlertModal/AlertModal.d.ts +11 -0
- package/dist/components/Modals/ConfirmationModal/ConfirmationModal.d.ts +26 -0
- package/dist/components/Modals/DecisionModal/DecisionModal.d.ts +37 -0
- package/dist/components/Modals/Modal.d.ts +45 -0
- package/dist/components/Navigation/Footer/Footer.d.ts +31 -0
- package/dist/components/Navigation/Header/DarkModeToggle/DarkModeToggle.d.ts +13 -0
- package/dist/components/Navigation/Header/Drawer.d.ts +18 -0
- package/dist/components/Navigation/Header/EnvironmentBanner.d.ts +4 -0
- package/dist/components/Navigation/Header/Header.d.ts +63 -0
- package/dist/components/Navigation/Header/ProfileMenu.d.ts +8 -0
- package/dist/components/Navigation/MenuButton/MenuButton.d.ts +9 -0
- package/dist/components/Navigation/NavBar/FloatingNavBar/FloatingNavBar.d.ts +24 -0
- package/dist/components/Navigation/NavBar/NavBar.d.ts +24 -0
- package/dist/components/Navigation/Sidebar/Sidebar.d.ts +14 -0
- package/dist/components/Navigation/Tabs/Tabs.d.ts +19 -0
- package/dist/components/PageHeader/PageHeader.d.ts +27 -0
- package/dist/components/SingleActionCard/SingleActionCard.d.ts +26 -0
- package/dist/components/Snackbar/Snackbar.d.ts +28 -0
- package/dist/components/Table/ExpandableRow/ExpandableRow.d.ts +16 -0
- package/dist/components/Table/PaginatedTable.d.ts +44 -0
- package/dist/components/Table/Table.d.ts +129 -0
- package/dist/index.cjs.js +410 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.es.js +63994 -0
- package/dist/index.umd.js +411 -0
- package/dist/styles/3-theme/ThemeDemo.d.ts +3 -0
- package/dist/styles/3-theme/theme.d.ts +16 -0
- package/dist/styles/theme.d.ts +33 -0
- package/package.json +140 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)<sup>1</sup>.
|
|
7
|
+
|
|
8
|
+
<sup>1</sup>We'll be following the following versioning practices to make it easier for devs to determine whether or not they are ready to upgrade to a newer verison of Mui Bueno:
|
|
9
|
+
|
|
10
|
+
- Major increment --> large/many changes. SEVERAL breaking changes.
|
|
11
|
+
- Minor increment --> singlular/minor changes. Minimal breaking changes.
|
|
12
|
+
- Patch increment --> singlular/minor changes. Zero breaking changes.
|
|
13
|
+
|
|
14
|
+
## [0.1.2] - 2025-07-09
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- Update index.ts to include MForm
|
|
18
|
+
|
|
19
|
+
## [0.1.1] - 2025-07-08
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- Converting existing input components for react-hook-form
|
|
23
|
+
- Components:
|
|
24
|
+
- Inputs
|
|
25
|
+
- AutoComplete
|
|
26
|
+
- Switch
|
|
27
|
+
|
|
28
|
+
## [0.1.0] - 2025-07-08
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
- Converting existing input components for react-hook-form
|
|
32
|
+
- Components:
|
|
33
|
+
- Inputs
|
|
34
|
+
- Checkbox
|
|
35
|
+
- CheckboxGroup
|
|
36
|
+
- DateField
|
|
37
|
+
- FileUPload
|
|
38
|
+
- RadioGroup
|
|
39
|
+
- RangeSlider
|
|
40
|
+
- Select
|
|
41
|
+
- Switch
|
|
42
|
+
- TextField
|
|
43
|
+
- RichTextField
|
|
44
|
+
- Error
|
|
45
|
+
- FormDebugger
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# MUI Bueno v3
|
|
2
|
+
|
|
3
|
+
A React component library based on [Material UI](https://mui.com/material-ui) components with built-in support for [Formik](https://formik.org/). Rebuilt & redesigned based on the original [mui-bueno](https://www.npmjs.com/package/mui-bueno) library, and expanded to provide additional components beyond form components.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
A product of the [SimonComputing Technology Innovations Lab](https://www.simoncomputing.com/technology-innovations-lab)
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install mui-bueno-v3
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Basic Example
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
<MForm>
|
|
19
|
+
<TextField label="First Name" name="first-name" />
|
|
20
|
+
<TextField name="lastName" label="Last Name" />
|
|
21
|
+
<TextField name="dob" label="Date of Birth" format="99/99/9999" placeholder="MM/DD/YYYY" />
|
|
22
|
+
<TextField name="email" label="Email" />
|
|
23
|
+
<Submit>Submit</Submit>
|
|
24
|
+
</MForm>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Documentation & Demo
|
|
28
|
+
|
|
29
|
+
This project uses Storybook to document and demonstrate the components. _URL COMING SOON._
|
|
30
|
+
|
|
31
|
+
## Release History
|
|
32
|
+
|
|
33
|
+
Details for every release are documented in [CHANGELOG.md](https://www.npmjs.com/package/mui-bueno-v3?activeTab=code)
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { ButtonProps } from '@mui/material';
|
|
2
|
+
export type ObjectWithId = {
|
|
3
|
+
id?: number | string;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
// TODO remove duplicate DTOs from golden ui, otherwise they'll be defined twice
|
|
7
|
+
// TODO bring over SimpleRequest & PageRequest too, for consistency?
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* State for the current page for pagination. NOTE: Use `PageRequest` for API calls.
|
|
11
|
+
*/
|
|
12
|
+
export type PageState = {
|
|
13
|
+
/**
|
|
14
|
+
* Page number (starts at 0) for paginated results.
|
|
15
|
+
*/
|
|
16
|
+
pageNo: number;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Page size for paginated results (number of rows).
|
|
20
|
+
*/
|
|
21
|
+
pageSize: number;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Paginated API response
|
|
26
|
+
*/
|
|
27
|
+
export type PageResponse<T> = {
|
|
28
|
+
data: T[];
|
|
29
|
+
pageNo: number;
|
|
30
|
+
pageSize: number;
|
|
31
|
+
totalCount: number;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Filter definition for narrowing down results from the service.
|
|
36
|
+
*/
|
|
37
|
+
export type Filter = {
|
|
38
|
+
column: string;
|
|
39
|
+
value: any;
|
|
40
|
+
/**
|
|
41
|
+
* These are the only supported operations for now
|
|
42
|
+
* More can be added in the future, but support may need to be added on the backend
|
|
43
|
+
* (i.e. ILIKE is a POSTGRES operation, the backend converts it to LIKE when using SQLITE)
|
|
44
|
+
*/
|
|
45
|
+
operation?: 'ILIKE' | '=' | 'IS DISTINCT FROM' | 'CLOSEST';
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type PaginationState = PageState & {
|
|
49
|
+
totalCount: number;
|
|
50
|
+
// searchTerm?: string;
|
|
51
|
+
sortField?: string;
|
|
52
|
+
sortOrder?: 'asc' | 'desc';
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
type LabelWithIcon = {
|
|
56
|
+
icon?: React.ReactElement;
|
|
57
|
+
label: string;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type MenuOption = LabelWithIcon & {
|
|
61
|
+
/**
|
|
62
|
+
* The minimum permission required to access this page (most commonly will be some sort of view permission).
|
|
63
|
+
*
|
|
64
|
+
* If not defined, this nav item will always be rendered in the navigation components regardless of user permissions.
|
|
65
|
+
* If defined, this nav item will be removed the navigation components if the user is missing the permission.
|
|
66
|
+
*
|
|
67
|
+
* @default undefined
|
|
68
|
+
*/
|
|
69
|
+
minPermission?: string | string[];
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Performs the action when clicked (ex. toggle dark mode). Avoid using this to navigate (use `path` or `externalLink` instead).
|
|
73
|
+
*
|
|
74
|
+
* When `path` or `externalLink` is defined, this onClick will run right before navigating. Use this to handle any non-navigation logic that needs to happen.
|
|
75
|
+
*/
|
|
76
|
+
onClick?: () => void; // TODO update this to allow for conditional navigating based on the return value (true = navigate, false = don't navigate)
|
|
77
|
+
} & (
|
|
78
|
+
| {
|
|
79
|
+
/**
|
|
80
|
+
* Internal path that this navigation item should navigate to (ex '/home')
|
|
81
|
+
*/
|
|
82
|
+
path: string;
|
|
83
|
+
externalLink?: never;
|
|
84
|
+
}
|
|
85
|
+
| {
|
|
86
|
+
/**
|
|
87
|
+
* External path that this navigation item should navigate to (ex 'https://www.google.com')
|
|
88
|
+
*/
|
|
89
|
+
externalLink: string;
|
|
90
|
+
path?: never;
|
|
91
|
+
}
|
|
92
|
+
| {
|
|
93
|
+
path?: never;
|
|
94
|
+
externalLink?: never;
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
export type EnvironmentInfo = {
|
|
99
|
+
env?: string; // ex 'Development'
|
|
100
|
+
isProd?: boolean;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* TableColumn represents a column in a table where `K` represents a property of `T`
|
|
105
|
+
* EXAMPLE: For a table of users, this would be the `TableColumn` defintion for the
|
|
106
|
+
* phone number column: TableColumn<User, Phone>.
|
|
107
|
+
*
|
|
108
|
+
* @property {string} label - Label that will display in the Table header for the column
|
|
109
|
+
* @property {string} fieldName - Property name of the object
|
|
110
|
+
* @property {(value: K, object: T, isMobile: boolean) => React.ReactNode} render - customize
|
|
111
|
+
* how the data is displayed in the column where `value` is the property value. `object`
|
|
112
|
+
* is the whole object, in case you need to determine styling based on another property
|
|
113
|
+
* within the object. isMobile in case your styling depends on whether the user is viewing
|
|
114
|
+
* on a phone vs tablet/desktop
|
|
115
|
+
* @property {string} sortName - (Optional) Passed instead of `fieldName` to onSortChange(fieldName, ...). Useful if you're rendering the same object in 2+ columns and need a way to differentiate when sorting.
|
|
116
|
+
*/
|
|
117
|
+
export type TableColumn<T, K> = {
|
|
118
|
+
key?: string;
|
|
119
|
+
label?: string;
|
|
120
|
+
fieldName: string;
|
|
121
|
+
render?: (value: K, object: T, isMobile: boolean) => React.ReactNode; // used to customize how the data `obj` is displayed in the table
|
|
122
|
+
sortName?: string;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// Sort order for Tables
|
|
126
|
+
export type SortOrder = 'asc' | 'desc';
|
|
127
|
+
|
|
128
|
+
export type TableConfig<T> = {
|
|
129
|
+
[K in keyof T]: TableColumn<T, T[K]>; // columns is an array of TableColumns, where the type of each TableColumn matches one of the properties of T (ex. `User`)
|
|
130
|
+
}[keyof T][];
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Convenience Interface for autocomplete dropdown options
|
|
134
|
+
* @label string displayed in the dropdown
|
|
135
|
+
* @value generic-type value associated with the option
|
|
136
|
+
*/
|
|
137
|
+
export interface AutocompleteOption<T> {
|
|
138
|
+
label: string;
|
|
139
|
+
value: T;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Checkbox Option
|
|
144
|
+
*
|
|
145
|
+
* Can be string OR:
|
|
146
|
+
* {
|
|
147
|
+
* label: string; // UI label
|
|
148
|
+
* sublabel?: string; // Smaller text that appears below UI label. Supplemental/help text.
|
|
149
|
+
* withTextField?: string; // Displays textfield for additional information needed from user (ex. "Other" checkbox). At mininmum, make sure to pass in `name` property.
|
|
150
|
+
* }
|
|
151
|
+
*/
|
|
152
|
+
export type CheckboxOption =
|
|
153
|
+
| string
|
|
154
|
+
| {
|
|
155
|
+
label: string;
|
|
156
|
+
sublabel?: string;
|
|
157
|
+
textField?: TextFieldProps;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Used for CitationField
|
|
162
|
+
* Represents a citation (web article/attachment/other url)
|
|
163
|
+
*/
|
|
164
|
+
export type Citation = {
|
|
165
|
+
id: number;
|
|
166
|
+
createdBy?: number;
|
|
167
|
+
updatedBy?: number;
|
|
168
|
+
deletedBy?: number;
|
|
169
|
+
|
|
170
|
+
fileName?: string;
|
|
171
|
+
url?: string;
|
|
172
|
+
title: string;
|
|
173
|
+
source?: string; // publisher
|
|
174
|
+
accessedAt?: string | null;
|
|
175
|
+
classification?: string; // public, unclassified
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Used for CitationField
|
|
180
|
+
* Used to represent a (potentially) unsaved Citation (no id defined yet)
|
|
181
|
+
*/
|
|
182
|
+
export type UnsavedCitation = {
|
|
183
|
+
id?: number;
|
|
184
|
+
} & Omit<Citation, 'id'>;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Used for CitationField
|
|
188
|
+
* Used to represent a (potentially) unsaved Attachment (same as UnsavedCitation but with a File obj)
|
|
189
|
+
*/
|
|
190
|
+
export type UnsavedAttachment = {
|
|
191
|
+
file?: File;
|
|
192
|
+
} & UnsavedCitation;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export declare const setMockDefaultValue: <T>(val: T) => void;
|
|
2
|
+
export declare const setMockErrorState: <T>(val: T) => void;
|
|
3
|
+
export declare const clearRHFMocks: () => void;
|
|
4
|
+
export declare const setValueSpy: import('vitest').Mock<(...args: any[]) => any>;
|
|
5
|
+
export declare const useFormContext: () => {
|
|
6
|
+
register: import('vitest').Mock<(...args: any[]) => any>;
|
|
7
|
+
handleSubmit: import('vitest').Mock<(...args: any[]) => any>;
|
|
8
|
+
formState: {
|
|
9
|
+
defaultValues: {
|
|
10
|
+
testCheckBox: unknown;
|
|
11
|
+
};
|
|
12
|
+
errors: {};
|
|
13
|
+
};
|
|
14
|
+
control: {};
|
|
15
|
+
setValue: import('vitest').Mock<(...args: any[]) => any>;
|
|
16
|
+
getValues: import('vitest').Mock<() => unknown>;
|
|
17
|
+
};
|
|
18
|
+
export declare const useForm: () => {
|
|
19
|
+
register: import('vitest').Mock<(...args: any[]) => any>;
|
|
20
|
+
handleSubmit: import('vitest').Mock<(...args: any[]) => any>;
|
|
21
|
+
formState: {
|
|
22
|
+
defaultValues: {
|
|
23
|
+
testCheckBox: unknown;
|
|
24
|
+
};
|
|
25
|
+
errors: {};
|
|
26
|
+
};
|
|
27
|
+
control: {};
|
|
28
|
+
};
|
|
29
|
+
interface ControllerProps {
|
|
30
|
+
name: string;
|
|
31
|
+
render: (params: {
|
|
32
|
+
field: {
|
|
33
|
+
name: string;
|
|
34
|
+
value: unknown;
|
|
35
|
+
onChange: (...args: any[]) => void;
|
|
36
|
+
onBlur: (...args: any[]) => void;
|
|
37
|
+
ref: (...args: any[]) => void;
|
|
38
|
+
};
|
|
39
|
+
fieldState: {
|
|
40
|
+
invalid: boolean;
|
|
41
|
+
isTouched: boolean;
|
|
42
|
+
isDirty: boolean;
|
|
43
|
+
error?: any;
|
|
44
|
+
};
|
|
45
|
+
formState: {
|
|
46
|
+
isSubmitting: boolean;
|
|
47
|
+
isValid: boolean;
|
|
48
|
+
defaultValues: unknown;
|
|
49
|
+
errors: unknown;
|
|
50
|
+
};
|
|
51
|
+
}) => Element;
|
|
52
|
+
}
|
|
53
|
+
export declare const Controller: ({ render, name }: ControllerProps) => Element;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { UseFormProps, FieldValues } from 'react-hook-form';
|
|
3
|
+
import { RenderResult } from '@testing-library/react';
|
|
4
|
+
interface RenderWithReactHookFormOptions<TFieldValues extends FieldValues> extends UseFormProps<TFieldValues> {
|
|
5
|
+
}
|
|
6
|
+
declare const renderWithReactHookForm: <TFieldValues extends Record<string, any>>(ui: ReactElement, options?: RenderWithReactHookFormOptions<TFieldValues>) => RenderResult;
|
|
7
|
+
export default renderWithReactHookForm;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { MenuOption } from '../../@types';
|
|
2
|
+
import { SelectOption } from '../../components/Form/Inputs/Select/Select';
|
|
3
|
+
export declare const isNumber: (char: number) => boolean;
|
|
4
|
+
export declare const isLetter: (char: number) => boolean;
|
|
5
|
+
export declare const autoformat: (input: string, format: string, currValue: string, element: HTMLInputElement) => string;
|
|
6
|
+
export declare const isFormatted: (item?: string, format?: string) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to remove unwanted prop fields from the provided props object
|
|
9
|
+
*
|
|
10
|
+
* @param props Props
|
|
11
|
+
* @param omit List of keys to omit from props
|
|
12
|
+
* @returns Clean props object
|
|
13
|
+
*/
|
|
14
|
+
export declare function removeStrayProps(props: Record<string, unknown>, omit: readonly string[]): object;
|
|
15
|
+
/**
|
|
16
|
+
* Converts string to label (ex. "this.isMy-string" --> "This Is My String")
|
|
17
|
+
*/
|
|
18
|
+
export declare const makeLabel: (s: string) => string;
|
|
19
|
+
/**
|
|
20
|
+
* Finds value/values in option list, and returns correct label string.
|
|
21
|
+
* If there are multiples values, the labels will be listed based on their order
|
|
22
|
+
* in the options list
|
|
23
|
+
* @param options Options
|
|
24
|
+
* @param value string
|
|
25
|
+
* @param multiple specifies if the value string will contain more than one value to
|
|
26
|
+
* @param placeholder placeholder to display in a field if the value is null
|
|
27
|
+
* @returns string representation of value
|
|
28
|
+
*/
|
|
29
|
+
export declare function renderValue<T>(options: SelectOption<T>[], value?: string, multiple?: boolean, placeholder?: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Generates the proper parameters for a MenuOption. For each `MenuOption`, if `path` is defined, but
|
|
32
|
+
* NOT `onClick`, it will behave as a link. Otherwise, it will behave as a button. In other words:
|
|
33
|
+
* path only --> link
|
|
34
|
+
* onClick only --> button
|
|
35
|
+
* path & onClick --> button (onClick will be executed before navigating to path)
|
|
36
|
+
*
|
|
37
|
+
* @param menuOption -- menuOption to generate the button/link props for
|
|
38
|
+
* @param naviate -- pass useNavigate's navigate fn. used when onClick & path are both present to navigate to the path
|
|
39
|
+
* @param onClickCallback -- (optional) called at the end of the onClick in case any additional execution is needed (ex. closing a modal)
|
|
40
|
+
*/
|
|
41
|
+
export declare function generateButtonLinkProps(menuOption: MenuOption, navigate: (path: string) => void, onClickCallback?: () => void): {
|
|
42
|
+
onClick: () => void;
|
|
43
|
+
component?: undefined;
|
|
44
|
+
to?: undefined;
|
|
45
|
+
href?: undefined;
|
|
46
|
+
} | {
|
|
47
|
+
component: import('react').ForwardRefExoticComponent<import('react-router-dom').LinkProps & import('react').RefAttributes<HTMLAnchorElement>>;
|
|
48
|
+
to: string;
|
|
49
|
+
onClick?: undefined;
|
|
50
|
+
href?: undefined;
|
|
51
|
+
} | {
|
|
52
|
+
href: string;
|
|
53
|
+
onClick?: undefined;
|
|
54
|
+
component?: undefined;
|
|
55
|
+
to?: undefined;
|
|
56
|
+
} | {
|
|
57
|
+
onClick?: undefined;
|
|
58
|
+
component?: undefined;
|
|
59
|
+
to?: undefined;
|
|
60
|
+
href?: undefined;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Opens the specified URL in a new tab
|
|
64
|
+
*/
|
|
65
|
+
export declare const launchTab: (url: string) => Window | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
interface WindowDimensions {
|
|
2
|
+
height: number;
|
|
3
|
+
width: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Gets the dimensions of the window (height and width in pixels)
|
|
7
|
+
* and updates the values on window resize.
|
|
8
|
+
*
|
|
9
|
+
* Some Mui Bueno components rely on the screen size to establish styling based on breakpoints.
|
|
10
|
+
* This function can be used to get the window width, without having to set a window context
|
|
11
|
+
* in the BForm component, as originally was occurring. Thus, components do not have to be nested
|
|
12
|
+
* in a BForm component in order to be styled properly.
|
|
13
|
+
*
|
|
14
|
+
* This function will not be exported from the library.
|
|
15
|
+
*
|
|
16
|
+
* **Example Usage**
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const { width } = useWindowDimensions();
|
|
19
|
+
* // or
|
|
20
|
+
* const { width, height } = useWindowDimensions();
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @returns Window dimensions
|
|
24
|
+
*/
|
|
25
|
+
export declare const useWindowDimensions: () => WindowDimensions;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AlertProps as MuiAlertProps } from '@mui/material/Alert/Alert';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
type BaseAlertProps = {
|
|
4
|
+
/** Hides the icon */
|
|
5
|
+
noIcon?: boolean;
|
|
6
|
+
/** Body of the alert. Recommend passing a string or component. */
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Variant of the alert: "standard", "filled", "outlined", or "leftBorder"
|
|
10
|
+
* @default leftBorder
|
|
11
|
+
*/
|
|
12
|
+
variant?: MuiAlertProps['variant'];
|
|
13
|
+
/** (optional) Title for the alert */
|
|
14
|
+
title?: string;
|
|
15
|
+
};
|
|
16
|
+
export type AlertProps = BaseAlertProps & Omit<MuiAlertProps, 'variant'>;
|
|
17
|
+
export type InternalAlertProps = Omit<AlertProps, 'color' | 'severity'>;
|
|
18
|
+
/**
|
|
19
|
+
* Compatible with all of MUI's Alert props EXCEPT FOR:
|
|
20
|
+
* - `severity` -- instead of `<Alert severity='success' {...props}>`, use `<SuccessAlert {...props}>`
|
|
21
|
+
* - `color` -- do not mix up severity colors
|
|
22
|
+
*
|
|
23
|
+
* Additional props:
|
|
24
|
+
* - `noIcon` -- icons are displayed by default. Use this to hide the icon.
|
|
25
|
+
*
|
|
26
|
+
* Modified props:
|
|
27
|
+
* - `variant` -- works with standard MUI variants: `standard`, `filled`, `outlined`, with one additional: `leftBorder` (default) which adds a border to the left of the alert matching the severity color
|
|
28
|
+
*/
|
|
29
|
+
export declare const Alert: (props: AlertProps) => import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export default Alert;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type BreadcrumbsProps = {
|
|
3
|
+
crumbInfo: BreadcrumbInfo[];
|
|
4
|
+
};
|
|
5
|
+
export type BreadcrumbInfo = {
|
|
6
|
+
label: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const Breadcrumbs: React.FC<BreadcrumbsProps>;
|
|
10
|
+
export default Breadcrumbs;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ButtonProps as MuiButtonProps } from '@mui/material';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
type BaseButtonProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Name of the button.
|
|
6
|
+
* @default 'button'
|
|
7
|
+
*/
|
|
8
|
+
name?: string;
|
|
9
|
+
/**
|
|
10
|
+
* If true, buttons become full width at the default xs Material-UI Breakpoint (form width < 600).
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
fullWidthOnMobile?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type ButtonProps = BaseButtonProps & MuiButtonProps;
|
|
16
|
+
/**
|
|
17
|
+
* Button doesn't have any default action. You may use for toggling or changing your own state.
|
|
18
|
+
* For type 'submit', use `Submit`
|
|
19
|
+
*
|
|
20
|
+
* To include the Button within the layout grid of MUI-Bueno, provide either a w or a breakpoint size (xs, sm, md, lg, xl).
|
|
21
|
+
* Otherwise, the button will be rendered as is (`<button>`).
|
|
22
|
+
*/
|
|
23
|
+
export declare const Button: React.FC<ButtonProps>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type ScrollToTopProps = {
|
|
2
|
+
label?: string;
|
|
3
|
+
icon?: React.ComponentType;
|
|
4
|
+
/**
|
|
5
|
+
* Number of pixels needed to scroll to toggle `trigger` to `true`. @default 100px
|
|
6
|
+
*/
|
|
7
|
+
scrollThresholdPx?: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* ScrollToTop is a FAB (Floating Action Button) that appears when the user scrolls down so that
|
|
11
|
+
* they can easily scroll back up by clicking on the FAB.
|
|
12
|
+
*/
|
|
13
|
+
export declare const ScrollToTop: (props: ScrollToTopProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export default ScrollToTop;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ButtonProps } from '../Button/Button';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export type SubmitProps = ButtonProps;
|
|
4
|
+
/**
|
|
5
|
+
* IMPORTANT: Has to be a child of Form
|
|
6
|
+
*
|
|
7
|
+
* This button will automatically submit the form. It accepts all the props that Button accepts, since it is a specific type of Button.
|
|
8
|
+
*
|
|
9
|
+
* This button does not have its own props; it uses the props from Button.
|
|
10
|
+
*/
|
|
11
|
+
export declare const Submit: React.FC<SubmitProps>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type ErrorProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Name of the component.
|
|
5
|
+
* @required
|
|
6
|
+
*/
|
|
7
|
+
name: string;
|
|
8
|
+
/**
|
|
9
|
+
* ID of the element.
|
|
10
|
+
* @required
|
|
11
|
+
*/
|
|
12
|
+
id: string;
|
|
13
|
+
/**
|
|
14
|
+
* Specifies the styling on the typography.
|
|
15
|
+
*/
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* This component provides a simple error block containing
|
|
20
|
+
* an error and status
|
|
21
|
+
*/
|
|
22
|
+
export declare const Error: React.FC<ErrorProps>;
|
|
23
|
+
export default Error;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* FormDebugger is a special convenience component developed to help debugging with React Hook Forms. FormDebugger will display field values currently in the form's state.
|
|
4
|
+
* It also displays the errors that currently exist along with the field that the error is associated to.
|
|
5
|
+
* Finally, this component displays the status 'errors' that arise when the form receives errors from the back-end service.
|
|
6
|
+
* These status 'errors' are also linked to specific fields within the form.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FormDebugger: React.FC;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { AutocompleteProps as MuiAutocompleteProps, TypographyProps } from '@mui/material';
|
|
2
|
+
export type BaseAutocompleteProps<T> = {
|
|
3
|
+
/**
|
|
4
|
+
* Name of the component. Must match a key from initialValues in Formik.
|
|
5
|
+
* @required
|
|
6
|
+
*/
|
|
7
|
+
name: string;
|
|
8
|
+
/**
|
|
9
|
+
* The label for the text field.
|
|
10
|
+
* @recommended
|
|
11
|
+
*/
|
|
12
|
+
label?: string;
|
|
13
|
+
/**
|
|
14
|
+
* List of options for the autocomplete in label/value format
|
|
15
|
+
* @recommended
|
|
16
|
+
*/
|
|
17
|
+
options: T[];
|
|
18
|
+
/**
|
|
19
|
+
* Specifies the visual input style.
|
|
20
|
+
* @default 'outlined'
|
|
21
|
+
*/
|
|
22
|
+
variant?: 'filled' | 'outlined' | 'standard';
|
|
23
|
+
/**
|
|
24
|
+
* If true, the prepackaged dynamic input label that comes with Material UI's input components
|
|
25
|
+
* will be replaced with a static typography label above the input.
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
staticLabel?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Props from MUI-Bueno's Typography component.
|
|
31
|
+
* Used to customize the label when the static label option is selected.
|
|
32
|
+
*/
|
|
33
|
+
staticLabelProps?: TypographyProps;
|
|
34
|
+
/**
|
|
35
|
+
* Margin for the FormControl
|
|
36
|
+
*/
|
|
37
|
+
margin?: 'dense' | 'none' | 'normal';
|
|
38
|
+
/**
|
|
39
|
+
* If true, an asterisk will be displayed next to the label
|
|
40
|
+
* Most browsers will automatically validate this, but it's recommended to also
|
|
41
|
+
* have Formik also validate as well so that `Error` displays for consistency.
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
required?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* When true, clears the input text when the user selects an option from the dropdown.
|
|
47
|
+
* Useful when adding items from the Autocomplete to a list or table.
|
|
48
|
+
*/
|
|
49
|
+
clearOnSelect?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* When using Autocomplete with objects, this prop can be used to store only a property of that object in formik.
|
|
52
|
+
*
|
|
53
|
+
* For example, if you have `type User = { id: number; firstName: string; lastName: string; ... }`, you can
|
|
54
|
+
* set useFieldAsValue="id" if you want formik to only store the user's id rather than the whole user object.
|
|
55
|
+
*
|
|
56
|
+
* NOTE: This will require extra processing on the client-side compared to just using the object for the formik value
|
|
57
|
+
* because the Autocomplete will have to search `options` for the object with the property matching formik's initial value.
|
|
58
|
+
*
|
|
59
|
+
*/
|
|
60
|
+
useFieldAsValue?: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Type used to define props passed into Autocomplete component
|
|
64
|
+
*/
|
|
65
|
+
export type AutocompleteProps<T> = BaseAutocompleteProps<T> & Omit<MuiAutocompleteProps<T, // Option type
|
|
66
|
+
false, // Multiple -- allows multiple options to be selected (enables `multiple` prop)
|
|
67
|
+
boolean, // DisableClearable -- allows disabling of the clear button (enables `disableClearable` prop)
|
|
68
|
+
false>, 'renderInput' | 'options' | 'value' | 'multiple' | 'freeSolo' | 'inputValue'>;
|
|
69
|
+
/**
|
|
70
|
+
* `Autocomplete` is a mix between a `TextField` and `Select` component.
|
|
71
|
+
* As the user types, options that match their query are presented.
|
|
72
|
+
*
|
|
73
|
+
* Use this component when you have a lot of options and want to reduce the amount of scrolling
|
|
74
|
+
* users would have to do if they were to use a `Select`.
|
|
75
|
+
*
|
|
76
|
+
* Can be used with primitives or objects. For objects, make sure to override `getOptionLabel`.
|
|
77
|
+
*
|
|
78
|
+
* __IMPORTANT__: If you need to dynamically load options as the user types, check out `DynamicAutocomplete`, as this
|
|
79
|
+
* has automated a lot of the settings.
|
|
80
|
+
*/
|
|
81
|
+
export declare const Autocomplete: <T>(props: AutocompleteProps<T>) => import("react/jsx-runtime").JSX.Element;
|