wcz-layout 6.7.2 → 8.3.2
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/dist/Approval-BTJTexDo.js +143 -0
- package/dist/Approval-BTJTexDo.js.map +1 -0
- package/dist/DialogsContext-DLqA8RJ_.js +7 -0
- package/dist/DialogsContext-DLqA8RJ_.js.map +1 -0
- package/dist/Email-C9qwj7GD.js +20 -0
- package/dist/Email-C9qwj7GD.js.map +1 -0
- package/dist/FileMeta-DDqUju1Y.js +19 -0
- package/dist/FileMeta-DDqUju1Y.js.map +1 -0
- package/dist/FileMeta-ILLTOjaM.d.ts +20 -0
- package/dist/NotificationContext-CgwUOeW0.js +7 -0
- package/dist/NotificationContext-CgwUOeW0.js.map +1 -0
- package/dist/RouterListItemButton-owZVvuC_.js +78 -0
- package/dist/RouterListItemButton-owZVvuC_.js.map +1 -0
- package/dist/User-CT_IDGuG.d.ts +15 -0
- package/dist/apiMiddleware-CtY4rOFU.js +23 -0
- package/dist/apiMiddleware-CtY4rOFU.js.map +1 -0
- package/dist/components.d.ts +118 -0
- package/dist/components.js +1554 -0
- package/dist/components.js.map +1 -0
- package/dist/data/client.d.ts +3111 -0
- package/dist/data/client.js +188 -0
- package/dist/data/client.js.map +1 -0
- package/dist/data/server.d.ts +19 -0
- package/dist/data/server.js +16 -0
- package/dist/data/server.js.map +1 -0
- package/dist/data.d.ts +7 -0
- package/dist/data.js +2 -0
- package/dist/env-ON-cyE3N.js +31 -0
- package/dist/env-ON-cyE3N.js.map +1 -0
- package/dist/file-BUdLb7H1.js +148 -0
- package/dist/file-BUdLb7H1.js.map +1 -0
- package/dist/file-Dsht7yOP.js +100 -0
- package/dist/file-Dsht7yOP.js.map +1 -0
- package/dist/hooks.d.ts +226 -0
- package/dist/hooks.js +1180 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +2106 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware.d.ts +47 -0
- package/dist/middleware.js +80 -0
- package/dist/middleware.js.map +1 -0
- package/dist/models.d.ts +474 -0
- package/dist/models.js +74 -0
- package/dist/models.js.map +1 -0
- package/dist/msalClient-CYiQAFnY.d.ts +15 -0
- package/dist/msalServer-B9sVqpQ2.js +47 -0
- package/dist/msalServer-B9sVqpQ2.js.map +1 -0
- package/dist/peoplesoft-BCjRje6b.js +240 -0
- package/dist/peoplesoft-BCjRje6b.js.map +1 -0
- package/dist/peoplesoft-Cze2ngGd.d.ts +1150 -0
- package/dist/queryClient-D64McLhZ.js +7 -0
- package/dist/queryClient-D64McLhZ.js.map +1 -0
- package/dist/useDialogs-BJVhBr8S.js +248 -0
- package/dist/useDialogs-BJVhBr8S.js.map +1 -0
- package/dist/utils-BMUmv2ws.js +191 -0
- package/dist/utils-BMUmv2ws.js.map +1 -0
- package/dist/utils-CvvyM8Xw.d.ts +56 -0
- package/dist/utils.d.ts +21 -0
- package/dist/utils.js +6 -0
- package/dist/vite.d.ts +7 -0
- package/dist/vite.js +147 -0
- package/dist/vite.js.map +1 -0
- package/package.json +158 -62
- package/skills/client-db/SKILL.md +107 -0
- package/skills/data-grid/SKILL.md +147 -0
- package/skills/db-schema/SKILL.md +68 -0
- package/skills/dialogs/SKILL.md +79 -0
- package/skills/forms/SKILL.md +82 -0
- package/skills/general/SKILL.md +17 -0
- package/skills/notifications/SKILL.md +43 -0
- package/skills/routing/SKILL.md +123 -0
- package/skills/server-functions/SKILL.md +109 -0
- package/skills/services/SKILL.md +28 -0
- package/skills/services/docs/approval.md +204 -0
- package/skills/services/docs/email.md +32 -0
- package/skills/services/docs/file.md +85 -0
- package/skills/services/docs/peoplesoft.md +110 -0
- package/skills/start/SKILL.md +46 -0
- package/skills/start/steps/01-git-setup.md +10 -0
- package/skills/start/steps/02-project-name-setup.md +14 -0
- package/skills/start/steps/03-apm-setup.md +208 -0
- package/skills/start/steps/04-database-setup.md +37 -0
- package/skills/start/steps/05-entra-setup.md +59 -0
- package/skills/start/steps/06-vault-setup.md +53 -0
- package/skills/start/steps/07-generate-favicon.md +10 -0
- package/skills/start/steps/08-commit.md +15 -0
- package/dist/src/components/Layout.d.ts +0 -16
- package/dist/src/components/Layout.js +0 -122
- package/dist/src/components/Layout.js.map +0 -1
- package/dist/src/components/dataGrid/ChipInputCell.d.ts +0 -9
- package/dist/src/components/dataGrid/ChipInputCell.js +0 -17
- package/dist/src/components/dataGrid/ChipInputCell.js.map +0 -1
- package/dist/src/components/dataGrid/EditableColumnHeader.d.ts +0 -2
- package/dist/src/components/dataGrid/EditableColumnHeader.js +0 -7
- package/dist/src/components/dataGrid/EditableColumnHeader.js.map +0 -1
- package/dist/src/components/dataGrid/GridToolbar.d.ts +0 -8
- package/dist/src/components/dataGrid/GridToolbar.js +0 -40
- package/dist/src/components/dataGrid/GridToolbar.js.map +0 -1
- package/dist/src/components/dataGrid/TableContainer.d.ts +0 -3
- package/dist/src/components/dataGrid/TableContainer.js +0 -32
- package/dist/src/components/dataGrid/TableContainer.js.map +0 -1
- package/dist/src/components/form/FormAutocomplete.d.ts +0 -7
- package/dist/src/components/form/FormAutocomplete.js +0 -10
- package/dist/src/components/form/FormAutocomplete.js.map +0 -1
- package/dist/src/components/form/FormCheckbox.d.ts +0 -7
- package/dist/src/components/form/FormCheckbox.js +0 -11
- package/dist/src/components/form/FormCheckbox.js.map +0 -1
- package/dist/src/components/form/FormDatePicker.d.ts +0 -9
- package/dist/src/components/form/FormDatePicker.js +0 -19
- package/dist/src/components/form/FormDatePicker.js.map +0 -1
- package/dist/src/components/form/FormDateTimePicker.d.ts +0 -9
- package/dist/src/components/form/FormDateTimePicker.js +0 -19
- package/dist/src/components/form/FormDateTimePicker.js.map +0 -1
- package/dist/src/components/form/FormNumberField.d.ts +0 -12
- package/dist/src/components/form/FormNumberField.js +0 -12
- package/dist/src/components/form/FormNumberField.js.map +0 -1
- package/dist/src/components/form/FormRadioGroup.d.ts +0 -13
- package/dist/src/components/form/FormRadioGroup.js +0 -11
- package/dist/src/components/form/FormRadioGroup.js.map +0 -1
- package/dist/src/components/form/FormSlider.d.ts +0 -7
- package/dist/src/components/form/FormSlider.js +0 -11
- package/dist/src/components/form/FormSlider.js.map +0 -1
- package/dist/src/components/form/FormSubmitButton.d.ts +0 -5
- package/dist/src/components/form/FormSubmitButton.js +0 -13
- package/dist/src/components/form/FormSubmitButton.js.map +0 -1
- package/dist/src/components/form/FormSwitch.d.ts +0 -7
- package/dist/src/components/form/FormSwitch.js +0 -11
- package/dist/src/components/form/FormSwitch.js.map +0 -1
- package/dist/src/components/form/FormTextField.d.ts +0 -7
- package/dist/src/components/form/FormTextField.js +0 -11
- package/dist/src/components/form/FormTextField.js.map +0 -1
- package/dist/src/components/layout/AccountMenu.d.ts +0 -9
- package/dist/src/components/layout/AccountMenu.js +0 -44
- package/dist/src/components/layout/AccountMenu.js.map +0 -1
- package/dist/src/components/layout/DevelopmentBanner.d.ts +0 -7
- package/dist/src/components/layout/DevelopmentBanner.js +0 -29
- package/dist/src/components/layout/DevelopmentBanner.js.map +0 -1
- package/dist/src/components/layout/ErrorPage.d.ts +0 -2
- package/dist/src/components/layout/ErrorPage.js +0 -25
- package/dist/src/components/layout/ErrorPage.js.map +0 -1
- package/dist/src/components/layout/LayoutDialog.d.ts +0 -12
- package/dist/src/components/layout/LayoutDialog.js +0 -12
- package/dist/src/components/layout/LayoutDialog.js.map +0 -1
- package/dist/src/components/layout/LayoutSnackbar.d.ts +0 -8
- package/dist/src/components/layout/LayoutSnackbar.js +0 -25
- package/dist/src/components/layout/LayoutSnackbar.js.map +0 -1
- package/dist/src/components/layout/NavigationDrawer.d.ts +0 -11
- package/dist/src/components/layout/NavigationDrawer.js +0 -70
- package/dist/src/components/layout/NavigationDrawer.js.map +0 -1
- package/dist/src/components/layout/NotificationMenu.d.ts +0 -8
- package/dist/src/components/layout/NotificationMenu.js +0 -26
- package/dist/src/components/layout/NotificationMenu.js.map +0 -1
- package/dist/src/components/layout/TypographyWithIcon.d.ts +0 -7
- package/dist/src/components/layout/TypographyWithIcon.js +0 -22
- package/dist/src/components/layout/TypographyWithIcon.js.map +0 -1
- package/dist/src/components/layout/Unauthorized.d.ts +0 -2
- package/dist/src/components/layout/Unauthorized.js +0 -26
- package/dist/src/components/layout/Unauthorized.js.map +0 -1
- package/dist/src/contexts/LayoutContext.d.ts +0 -40
- package/dist/src/contexts/LayoutContext.js +0 -60
- package/dist/src/contexts/LayoutContext.js.map +0 -1
- package/dist/src/contexts/UserContext.d.ts +0 -24
- package/dist/src/contexts/UserContext.js +0 -55
- package/dist/src/contexts/UserContext.js.map +0 -1
- package/dist/src/hooks/FormHooks.d.ts +0 -46
- package/dist/src/hooks/FormHooks.js +0 -31
- package/dist/src/hooks/FormHooks.js.map +0 -1
- package/dist/src/hooks/UseSnackbar.d.ts +0 -10
- package/dist/src/hooks/UseSnackbar.js +0 -23
- package/dist/src/hooks/UseSnackbar.js.map +0 -1
- package/dist/src/hooks/UseUser.d.ts +0 -10
- package/dist/src/hooks/UseUser.js +0 -25
- package/dist/src/hooks/UseUser.js.map +0 -1
- package/dist/src/index.d.ts +0 -20
- package/dist/src/index.js +0 -15
- package/dist/src/index.js.map +0 -1
- package/dist/src/models/Error.d.ts +0 -6
- package/dist/src/models/Error.js +0 -2
- package/dist/src/models/Error.js.map +0 -1
- package/dist/src/models/KeycloakSettings.d.ts +0 -8
- package/dist/src/models/KeycloakSettings.js +0 -2
- package/dist/src/models/KeycloakSettings.js.map +0 -1
- package/dist/src/models/LayoutPaletteColorOptions.d.ts +0 -6
- package/dist/src/models/LayoutPaletteColorOptions.js +0 -2
- package/dist/src/models/LayoutPaletteColorOptions.js.map +0 -1
- package/dist/src/models/LayoutRoute.d.ts +0 -14
- package/dist/src/models/LayoutRoute.js +0 -2
- package/dist/src/models/LayoutRoute.js.map +0 -1
- package/dist/src/models/Notification.d.ts +0 -9
- package/dist/src/models/Notification.js +0 -2
- package/dist/src/models/Notification.js.map +0 -1
- package/dist/src/models/PeoplesoftDepartment.d.ts +0 -14
- package/dist/src/models/PeoplesoftDepartment.js +0 -2
- package/dist/src/models/PeoplesoftDepartment.js.map +0 -1
- package/dist/src/models/PeoplesoftEmployee.d.ts +0 -34
- package/dist/src/models/PeoplesoftEmployee.js +0 -2
- package/dist/src/models/PeoplesoftEmployee.js.map +0 -1
- package/dist/src/models/Snackbar.d.ts +0 -15
- package/dist/src/models/Snackbar.js +0 -2
- package/dist/src/models/Snackbar.js.map +0 -1
- package/dist/src/models/User.d.ts +0 -27
- package/dist/src/models/User.js +0 -11
- package/dist/src/models/User.js.map +0 -1
- package/dist/src/models/types/EmployeeCategoryGroup.d.ts +0 -1
- package/dist/src/models/types/EmployeeCategoryGroup.js +0 -2
- package/dist/src/models/types/EmployeeCategoryGroup.js.map +0 -1
- package/dist/src/models/types/EmployeeStatus.d.ts +0 -1
- package/dist/src/models/types/EmployeeStatus.js +0 -2
- package/dist/src/models/types/EmployeeStatus.js.map +0 -1
- package/dist/src/utils/Auth.d.ts +0 -12
- package/dist/src/utils/Auth.js +0 -49
- package/dist/src/utils/Auth.js.map +0 -1
- package/dist/src/utils/Fetches.d.ts +0 -5
- package/dist/src/utils/Fetches.js +0 -66
- package/dist/src/utils/Fetches.js.map +0 -1
- package/dist/src/utils/FormUtils.d.ts +0 -7
- package/dist/src/utils/FormUtils.js +0 -9
- package/dist/src/utils/FormUtils.js.map +0 -1
- package/dist/src/utils/Helpers.d.ts +0 -11
- package/dist/src/utils/Helpers.js +0 -26
- package/dist/src/utils/Helpers.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/components/Layout.tsx +0 -183
- package/src/components/dataGrid/ChipInputCell.tsx +0 -31
- package/src/components/dataGrid/EditableColumnHeader.tsx +0 -7
- package/src/components/dataGrid/GridToolbar.tsx +0 -63
- package/src/components/dataGrid/TableContainer.tsx +0 -39
- package/src/components/form/FormAutocomplete.tsx +0 -34
- package/src/components/form/FormCheckbox.tsx +0 -32
- package/src/components/form/FormDatePicker.tsx +0 -34
- package/src/components/form/FormDateTimePicker.tsx +0 -34
- package/src/components/form/FormNumberField.tsx +0 -33
- package/src/components/form/FormRadioGroup.tsx +0 -43
- package/src/components/form/FormSlider.tsx +0 -28
- package/src/components/form/FormSubmitButton.tsx +0 -29
- package/src/components/form/FormSwitch.tsx +0 -32
- package/src/components/form/FormTextField.tsx +0 -26
- package/src/components/layout/AccountMenu.tsx +0 -160
- package/src/components/layout/DevelopmentBanner.tsx +0 -54
- package/src/components/layout/ErrorPage.tsx +0 -34
- package/src/components/layout/LayoutDialog.tsx +0 -50
- package/src/components/layout/LayoutSnackbar.tsx +0 -44
- package/src/components/layout/NavigationDrawer.tsx +0 -131
- package/src/components/layout/NotificationMenu.tsx +0 -76
- package/src/components/layout/TypographyWithIcon.tsx +0 -35
- package/src/components/layout/Unauthorized.tsx +0 -37
- package/src/contexts/LayoutContext.tsx +0 -127
- package/src/contexts/UserContext.tsx +0 -88
- package/src/hooks/FormHooks.ts +0 -33
- package/src/hooks/UseSnackbar.tsx +0 -28
- package/src/hooks/UseUser.tsx +0 -29
- package/src/index.ts +0 -27
- package/src/models/Error.tsx +0 -6
- package/src/models/KeycloakSettings.ts +0 -8
- package/src/models/LayoutPaletteColorOptions.tsx +0 -7
- package/src/models/LayoutRoute.ts +0 -15
- package/src/models/Notification.ts +0 -10
- package/src/models/PeoplesoftDepartment.ts +0 -15
- package/src/models/PeoplesoftEmployee.ts +0 -35
- package/src/models/Snackbar.ts +0 -16
- package/src/models/User.ts +0 -13
- package/src/models/types/EmployeeCategoryGroup.ts +0 -1
- package/src/models/types/EmployeeStatus.ts +0 -1
- package/src/utils/Auth.ts +0 -58
- package/src/utils/Fetches.ts +0 -83
- package/src/utils/FormUtils.ts +0 -22
- package/src/utils/Helpers.ts +0 -27
- package/tsconfig.json +0 -29
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { Menu } from "@mui/icons-material";
|
|
2
|
-
import { Box, Chip, CssBaseline, IconButton, LinearProgress, AppBar as MuiAppBar, AppBarProps as MuiAppBarProps, Theme, Toolbar, Typography, useMediaQuery } from "@mui/material";
|
|
3
|
-
import { grey } from "@mui/material/colors";
|
|
4
|
-
import { csCZ, enUS } from "@mui/material/locale";
|
|
5
|
-
import { ThemeProvider, createTheme, styled } from "@mui/material/styles";
|
|
6
|
-
import { csCZ as dataGridCsCz, enUS as dataGridEnUs } from "@mui/x-data-grid-premium/locales";
|
|
7
|
-
import { csCZ as datePickersCsCz, enUS as datePickersEnUs } from "@mui/x-date-pickers-pro/locales";
|
|
8
|
-
import { useIsFetching, useIsMutating } from "@tanstack/react-query";
|
|
9
|
-
import React, { Dispatch, SetStateAction, useEffect, useState } from "react";
|
|
10
|
-
import { useTranslation } from "react-i18next";
|
|
11
|
-
import { matchPath, useLocation } from "react-router-dom";
|
|
12
|
-
import { LayoutPaletteColorOptions } from "../models/LayoutPaletteColorOptions";
|
|
13
|
-
import { LayoutRoute } from "../models/LayoutRoute";
|
|
14
|
-
import Notification from "../models/Notification";
|
|
15
|
-
import { User } from "../models/User";
|
|
16
|
-
import { environment } from "../utils/Helpers";
|
|
17
|
-
import { AccountMenu } from "./layout/AccountMenu";
|
|
18
|
-
import { DevelopmentBanner } from "./layout/DevelopmentBanner";
|
|
19
|
-
import { NavigationDrawer } from "./layout/NavigationDrawer";
|
|
20
|
-
import { NotificationMenu } from "./layout/NotificationMenu";
|
|
21
|
-
import { Unauthorized } from "./layout/Unauthorized";
|
|
22
|
-
import useLocalStorageState from "use-local-storage-state";
|
|
23
|
-
import { useIsAuthenticated, useMsal } from "@azure/msal-react";
|
|
24
|
-
import { InteractionStatus } from "@azure/msal-browser";
|
|
25
|
-
|
|
26
|
-
//Drawer
|
|
27
|
-
const drawerWidth = 240;
|
|
28
|
-
const DrawerHeader = styled("div")(({ theme }) => ({
|
|
29
|
-
display: "flex",
|
|
30
|
-
alignItems: "center",
|
|
31
|
-
justifyContent: "flex-end",
|
|
32
|
-
padding: theme.spacing(0, 1),
|
|
33
|
-
// necessary for content to be below app bar
|
|
34
|
-
...theme.mixins.toolbar,
|
|
35
|
-
}));
|
|
36
|
-
|
|
37
|
-
//AppBar
|
|
38
|
-
interface AppBarProps extends MuiAppBarProps {
|
|
39
|
-
open?: boolean;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const AppBar = styled(MuiAppBar, {
|
|
43
|
-
shouldForwardProp: (prop) => prop !== "open",
|
|
44
|
-
})<AppBarProps>(({ theme, open }) => ({
|
|
45
|
-
zIndex: theme.zIndex.drawer + 1,
|
|
46
|
-
transition: theme.transitions.create(["width", "margin"], {
|
|
47
|
-
easing: theme.transitions.easing.sharp,
|
|
48
|
-
duration: theme.transitions.duration.leavingScreen,
|
|
49
|
-
}),
|
|
50
|
-
...(open && {
|
|
51
|
-
marginLeft: drawerWidth,
|
|
52
|
-
width: `calc(100% - ${drawerWidth}px)`,
|
|
53
|
-
transition: theme.transitions.create(["width", "margin"], {
|
|
54
|
-
easing: theme.transitions.easing.sharp,
|
|
55
|
-
duration: theme.transitions.duration.enteringScreen,
|
|
56
|
-
}),
|
|
57
|
-
}),
|
|
58
|
-
}));
|
|
59
|
-
|
|
60
|
-
const getAllRoutesWithPath = (routes: LayoutRoute[]): LayoutRoute[] => {
|
|
61
|
-
let result: LayoutRoute[] = [];
|
|
62
|
-
for (const route of routes) {
|
|
63
|
-
if (route.path) {
|
|
64
|
-
result.push(route);
|
|
65
|
-
}
|
|
66
|
-
if (route.children) {
|
|
67
|
-
result = result.concat(getAllRoutesWithPath(route.children));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return result;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
interface LayoutProps {
|
|
74
|
-
routes: LayoutRoute[];
|
|
75
|
-
appVersion: string;
|
|
76
|
-
colors: LayoutPaletteColorOptions;
|
|
77
|
-
children: React.ReactNode;
|
|
78
|
-
user: User;
|
|
79
|
-
notifications: Notification[] | undefined;
|
|
80
|
-
setNotifications: Dispatch<SetStateAction<Notification[] | undefined>>;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export const Layout: React.FC<LayoutProps> = ({ routes, colors, appVersion, user, notifications, setNotifications, children }) => {
|
|
84
|
-
const prefersDarkMode: boolean = useMediaQuery("(prefers-color-scheme: dark)");
|
|
85
|
-
const [mode, setMode] = useLocalStorageState<"light" | "dark" | "system">("mui-mode", { defaultValue: "system" });
|
|
86
|
-
const [leftDrawerOpen, setLeftDrawerOpen] = useState<boolean>(false);
|
|
87
|
-
const { i18n } = useTranslation();
|
|
88
|
-
const isFetching = !!useIsFetching();
|
|
89
|
-
const isMutating = !!useIsMutating();
|
|
90
|
-
const location = useLocation();
|
|
91
|
-
const navigationRoutes = getAllRoutesWithPath(routes);
|
|
92
|
-
const route = navigationRoutes.find(r => matchPath(r.path!, location.pathname))!;
|
|
93
|
-
const { instance, inProgress } = useMsal();
|
|
94
|
-
const isAuthenticated = useIsAuthenticated();
|
|
95
|
-
|
|
96
|
-
useEffect(() => {
|
|
97
|
-
if (route.authenticated !== false && !isAuthenticated && inProgress === InteractionStatus.None)
|
|
98
|
-
instance.loginRedirect({ scopes: [], redirectUri: "/" });
|
|
99
|
-
}, [route, isAuthenticated, inProgress]);
|
|
100
|
-
|
|
101
|
-
const resolvedMode = mode === "system" ? (prefersDarkMode ? "dark" : "light") : mode;
|
|
102
|
-
|
|
103
|
-
const theme: Theme = createTheme({
|
|
104
|
-
palette: {
|
|
105
|
-
mode: resolvedMode,
|
|
106
|
-
primary: { main: (colors.primary as any)?.[resolvedMode] || (colors.primary as any)?.main, },
|
|
107
|
-
secondary: { main: (colors.secondary as any)?.[resolvedMode] || (colors.secondary as any)?.main, },
|
|
108
|
-
background: resolvedMode === "light" && colors.background ? { default: colors.background.default, paper: colors.background.paper, } : {},
|
|
109
|
-
},
|
|
110
|
-
components: {
|
|
111
|
-
MuiCssBaseline: {
|
|
112
|
-
styleOverrides: (theme) => ({
|
|
113
|
-
body: {
|
|
114
|
-
"&::-webkit-scrollbar, & *::-webkit-scrollbar": {
|
|
115
|
-
width: "0.7em",
|
|
116
|
-
height: "0.7em",
|
|
117
|
-
},
|
|
118
|
-
"&::-webkit-scrollbar-track, & *::-webkit-scrollbar-track": {
|
|
119
|
-
backgroundColor: theme.palette.mode === "dark" ? grey[900] : grey[200],
|
|
120
|
-
borderRadius: "5px",
|
|
121
|
-
},
|
|
122
|
-
"&::-webkit-scrollbar-thumb, & *::-webkit-scrollbar-thumb": {
|
|
123
|
-
backgroundColor: theme.palette.mode === "dark" ? grey[800] : grey[400],
|
|
124
|
-
borderRadius: "10px",
|
|
125
|
-
},
|
|
126
|
-
"&::-webkit-scrollbar-thumb:hover, & *::-webkit-scrollbar-thumb:hover": {
|
|
127
|
-
backgroundColor: theme.palette.mode === "dark" ? grey[700] : grey[500],
|
|
128
|
-
},
|
|
129
|
-
"&::-webkit-scrollbar-corner, & *::-webkit-scrollbar-corner": {
|
|
130
|
-
backgroundColor: "transparent",
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
}),
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
i18n.language === "cs" ? datePickersCsCz : datePickersEnUs,
|
|
138
|
-
i18n.language === "cs" ? dataGridCsCz : dataGridEnUs,
|
|
139
|
-
i18n.language === "cs" ? csCZ : enUS
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
const title = route.pageTitle ?? route.title;
|
|
143
|
-
|
|
144
|
-
useEffect(() => {
|
|
145
|
-
if (title) document.title = title;
|
|
146
|
-
}, [title]);
|
|
147
|
-
|
|
148
|
-
const toggleNavigationDrawer = () => setLeftDrawerOpen(!leftDrawerOpen);
|
|
149
|
-
|
|
150
|
-
const hasNavigationRoutes: boolean = navigationRoutes.filter(route => route.showInMenu && !route.disabled).length > 1;
|
|
151
|
-
|
|
152
|
-
return (
|
|
153
|
-
<ThemeProvider theme={theme}>
|
|
154
|
-
<Box sx={{ display: "flex", position: "sticky" }}>
|
|
155
|
-
<CssBaseline />
|
|
156
|
-
<AppBar position="fixed" open={leftDrawerOpen}>
|
|
157
|
-
<Toolbar>
|
|
158
|
-
<IconButton color="inherit" onClick={toggleNavigationDrawer} edge="start" sx={{ marginRight: 2, ...((leftDrawerOpen || !hasNavigationRoutes) && { display: "none" }) }} >
|
|
159
|
-
<Menu />
|
|
160
|
-
</IconButton>
|
|
161
|
-
|
|
162
|
-
<Typography variant="h6" noWrap component="div" sx={{ flexGrow: 1 }}>{title}</Typography>
|
|
163
|
-
|
|
164
|
-
{environment !== "prd" && <Chip sx={theme => ({ mr: 1, bgcolor: "secondary.main", color: theme.palette.primary.contrastText })} label={environment} />}
|
|
165
|
-
|
|
166
|
-
<NotificationMenu notifications={notifications} setNotifications={setNotifications} />
|
|
167
|
-
<AccountMenu mode={mode} setMode={setMode} user={user}/>
|
|
168
|
-
</Toolbar>
|
|
169
|
-
</AppBar>
|
|
170
|
-
|
|
171
|
-
<NavigationDrawer routes={navigationRoutes} appVersion={appVersion} open={leftDrawerOpen} setOpen={setLeftDrawerOpen} hasRoutes={hasNavigationRoutes} />
|
|
172
|
-
|
|
173
|
-
<Box component="main" sx={{ flex: 1, overflow: "auto" }}>
|
|
174
|
-
<DrawerHeader />
|
|
175
|
-
{(route.authenticated === false || isAuthenticated) && !route.disabled ? children : <Unauthorized />}
|
|
176
|
-
</Box>
|
|
177
|
-
</Box>
|
|
178
|
-
|
|
179
|
-
<DevelopmentBanner user={user} hasNavigationRoutes={hasNavigationRoutes} />
|
|
180
|
-
{(isFetching || isMutating) && <LinearProgress sx={{ position: "fixed", top: { xs: 56, sm: 64 }, left: 0, right: 0 }} />}
|
|
181
|
-
</ThemeProvider>
|
|
182
|
-
);
|
|
183
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Chip, ChipProps, Stack } from "@mui/material";
|
|
2
|
-
import { GridRenderCellParams, GridValidRowModel } from "@mui/x-data-grid-premium";
|
|
3
|
-
import { newGuid } from "../../utils/Helpers";
|
|
4
|
-
|
|
5
|
-
const isArray = (value: any) => Array.isArray(value);
|
|
6
|
-
|
|
7
|
-
interface ChipInputCellProps<T extends GridValidRowModel> {
|
|
8
|
-
params: GridRenderCellParams<T>;
|
|
9
|
-
slotProps?: ChipProps;
|
|
10
|
-
getLabel?: (object: T) => string | number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const ChipInputCell = <T extends GridValidRowModel>({ params, slotProps, getLabel }: ChipInputCellProps<T>) => {
|
|
14
|
-
if (!params.value) return null;
|
|
15
|
-
|
|
16
|
-
const getLabelValue = (value: any) => {
|
|
17
|
-
if (getLabel) return getLabel(value);
|
|
18
|
-
return value;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
if (isArray(params.value))
|
|
22
|
-
return (
|
|
23
|
-
<Stack direction="row" alignItems="center" gap={1} sx={{ overflowX: "auto", height: "100%", width: params.colDef.computedWidth }}>
|
|
24
|
-
{params.value.map((value: any) =>
|
|
25
|
-
<Chip key={newGuid()} label={getLabelValue(value)} {...slotProps} />
|
|
26
|
-
)}
|
|
27
|
-
</Stack>
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
return <Chip label={getLabelValue(params.value)} {...slotProps} />;
|
|
31
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Edit } from "@mui/icons-material";
|
|
2
|
-
import { GridColumnHeaderParams, GridValidRowModel } from "@mui/x-data-grid-premium";
|
|
3
|
-
import { TypographyWithIcon } from "../layout/TypographyWithIcon";
|
|
4
|
-
|
|
5
|
-
export const EditableColumnHeader = <T extends GridValidRowModel>({ colDef }: GridColumnHeaderParams<T>) => {
|
|
6
|
-
return <TypographyWithIcon endIcon={<Edit color="disabled" fontSize="small" />} variant="body2" className="MuiDataGrid-columnHeaderTitle">{colDef.headerName}</TypographyWithIcon>;
|
|
7
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Add } from "@mui/icons-material";
|
|
2
|
-
import { Box, Button } from "@mui/material";
|
|
3
|
-
import { GridRowId, GridToolbarColumnsButton, GridToolbarContainer, GridToolbarExport, GridToolbarFilterButton, GridToolbarQuickFilter, GridToolbarProps as MuiGridToolbarProps, useGridApiContext } from "@mui/x-data-grid-premium";
|
|
4
|
-
import { GridApiPremium } from "@mui/x-data-grid-premium/models/gridApiPremium";
|
|
5
|
-
import React, { useContext } from "react";
|
|
6
|
-
import { LayoutContext } from "../../contexts/LayoutContext";
|
|
7
|
-
import { newGuid } from "../../utils/Helpers";
|
|
8
|
-
|
|
9
|
-
const getFirstEditableColumn = (apiRef: GridApiPremium) => {
|
|
10
|
-
const editableColumns = apiRef.getAllColumns().filter(column => column.editable);
|
|
11
|
-
if (editableColumns.length)
|
|
12
|
-
return editableColumns[0];
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const hasEditableColumn = (apiRef: GridApiPremium | null) => {
|
|
16
|
-
const editableColumns = apiRef?.getAllColumns().filter(column => column.editable);
|
|
17
|
-
return !!editableColumns?.length;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export interface GridToolbarProps extends MuiGridToolbarProps {
|
|
21
|
-
actions?: React.ReactNode[];
|
|
22
|
-
hideAddNewRow?: boolean;
|
|
23
|
-
newRowDefaultValue?: any;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const GridToolbar: React.FC<GridToolbarProps> = (props) => {
|
|
27
|
-
const apiRef = useGridApiContext();
|
|
28
|
-
const { t } = useContext(LayoutContext);
|
|
29
|
-
|
|
30
|
-
const handleOnAddRecordClick = () => {
|
|
31
|
-
if (!apiRef.current) return;
|
|
32
|
-
|
|
33
|
-
const rowIds: GridRowId[] = apiRef.current?.getAllRowIds();
|
|
34
|
-
const allRows: any[] = rowIds.map(rowId => (apiRef.current?.getRow(rowId)));
|
|
35
|
-
|
|
36
|
-
const id: GridRowId = props.newRowDefaultValue?.id ?? newGuid();
|
|
37
|
-
apiRef.current?.setRows([{ ...props.newRowDefaultValue, id, isNew: true }, ...allRows]);
|
|
38
|
-
setTimeout(() => apiRef.current?.startRowEditMode({ id }));
|
|
39
|
-
|
|
40
|
-
const firstEditableColumn = getFirstEditableColumn(apiRef.current);
|
|
41
|
-
if (firstEditableColumn) {
|
|
42
|
-
apiRef.current.setCellFocus(id, firstEditableColumn.field);
|
|
43
|
-
setTimeout(() => apiRef.current?.scrollToIndexes({ rowIndex: 0 }));
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const showNewRowButton = hasEditableColumn(apiRef.current) && !props.hideAddNewRow;
|
|
48
|
-
const hasActiveFilters = !!apiRef.current?.state.filter.filterModel.items.length || !!apiRef.current?.state.filter.filterModel.quickFilterValues?.length;
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<GridToolbarContainer>
|
|
52
|
-
<GridToolbarColumnsButton />
|
|
53
|
-
<GridToolbarFilterButton />
|
|
54
|
-
<GridToolbarExport />
|
|
55
|
-
{showNewRowButton && <Button size="small" startIcon={<Add />} onClick={handleOnAddRecordClick} disabled={hasActiveFilters}>{t("Layout.AddRow")}</Button>}
|
|
56
|
-
{props.actions?.map(action => action)}
|
|
57
|
-
|
|
58
|
-
<Box sx={{ flexGrow: 1 }} />
|
|
59
|
-
|
|
60
|
-
<GridToolbarQuickFilter />
|
|
61
|
-
</GridToolbarContainer>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Box, BoxProps, useTheme } from "@mui/material";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
export const TableContainer: React.FC<BoxProps> = ({ sx, ...props }) => {
|
|
5
|
-
const theme = useTheme();
|
|
6
|
-
|
|
7
|
-
return (
|
|
8
|
-
<Box
|
|
9
|
-
{...props}
|
|
10
|
-
sx={{
|
|
11
|
-
height: { xs: "calc(100vh - 56px)", sm: "calc(100vh - 64px)" },
|
|
12
|
-
"& .MuiDataGrid-cell--editing": {
|
|
13
|
-
"& .MuiInputBase-root": {
|
|
14
|
-
height: "100%",
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
"& .MuiDataGrid-columnHeaderTitle": {
|
|
18
|
-
fontWeight: "600",
|
|
19
|
-
},
|
|
20
|
-
"& .MuiDataGrid-cell": {
|
|
21
|
-
display: "flex",
|
|
22
|
-
alignItems: "center",
|
|
23
|
-
},
|
|
24
|
-
"& .Mui-error": {
|
|
25
|
-
backgroundColor: theme.palette.error.main,
|
|
26
|
-
color: theme.palette.error.contrastText
|
|
27
|
-
},
|
|
28
|
-
"& .MuiDataGrid-booleanCell[data-value=\"true\"]": {
|
|
29
|
-
color: `${theme.palette.success.main}!important`
|
|
30
|
-
},
|
|
31
|
-
"& .MuiDataGrid-booleanCell[data-value=\"false\"]": {
|
|
32
|
-
color: `${theme.palette.error.main}!important`
|
|
33
|
-
},
|
|
34
|
-
...sx
|
|
35
|
-
}}>
|
|
36
|
-
{props.children}
|
|
37
|
-
</Box>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Autocomplete, AutocompleteProps, TextField, TextFieldProps } from "@mui/material";
|
|
2
|
-
import { FC } from "react";
|
|
3
|
-
|
|
4
|
-
import { FormOmittedProps, getFieldStatus } from "../../utils/FormUtils";
|
|
5
|
-
import { useFieldContext } from "../../hooks/FormHooks";
|
|
6
|
-
|
|
7
|
-
export interface FormAutocompleteProps extends Omit<AutocompleteProps<any, boolean, boolean, boolean>, FormOmittedProps> {
|
|
8
|
-
textFieldProps?: Omit<TextFieldProps, FormOmittedProps>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const FormAutocomplete: FC<FormAutocompleteProps> = ({ textFieldProps, ...autocompleteProps }) => {
|
|
12
|
-
const field = useFieldContext();
|
|
13
|
-
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<Autocomplete
|
|
17
|
-
value={field.state.value}
|
|
18
|
-
onChange={(_, value) => !autocompleteProps.freeSolo && field.handleChange(value)}
|
|
19
|
-
onInputChange={(_, value, reason) => reason !== "reset" && autocompleteProps.freeSolo && field.handleChange(value)}
|
|
20
|
-
onBlur={field.handleBlur}
|
|
21
|
-
aria-label={field.name}
|
|
22
|
-
{...autocompleteProps}
|
|
23
|
-
renderInput={(params) =>
|
|
24
|
-
<TextField
|
|
25
|
-
{...params}
|
|
26
|
-
name={field.name}
|
|
27
|
-
error={isTouched && hasError}
|
|
28
|
-
helperText={isTouched && helperText}
|
|
29
|
-
{...textFieldProps}
|
|
30
|
-
/>
|
|
31
|
-
}
|
|
32
|
-
/>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Checkbox, CheckboxProps, FormControl, FormControlLabel, FormHelperText } from "@mui/material";
|
|
2
|
-
import { FC } from "react";
|
|
3
|
-
import { useFieldContext } from "../../hooks/FormHooks";
|
|
4
|
-
import { FormOmittedProps, getFieldStatus } from "../../utils/FormUtils";
|
|
5
|
-
|
|
6
|
-
export interface FormCheckboxProps extends Omit<CheckboxProps, FormOmittedProps> {
|
|
7
|
-
label?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const FormCheckbox: FC<FormCheckboxProps> = (props) => {
|
|
11
|
-
const field = useFieldContext<boolean | null | undefined>();
|
|
12
|
-
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<FormControl component="fieldset">
|
|
16
|
-
<FormControlLabel
|
|
17
|
-
control={
|
|
18
|
-
<Checkbox
|
|
19
|
-
name={field.name}
|
|
20
|
-
checked={Boolean(field.state.value)}
|
|
21
|
-
onChange={(e) => field.handleChange(e.target.checked)}
|
|
22
|
-
onBlur={field.handleBlur}
|
|
23
|
-
aria-label={field.name}
|
|
24
|
-
{...props}
|
|
25
|
-
/>
|
|
26
|
-
}
|
|
27
|
-
label={props.label ?? ""}
|
|
28
|
-
/>
|
|
29
|
-
{isTouched && hasError && <FormHelperText error={hasError}>{helperText}</FormHelperText>}
|
|
30
|
-
</FormControl>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { TextFieldProps } from "@mui/material";
|
|
2
|
-
import { DatePicker, DatePickerProps } from "@mui/x-date-pickers-pro";
|
|
3
|
-
import { FC } from "react";
|
|
4
|
-
import { useFieldContext } from "../../hooks/FormHooks";
|
|
5
|
-
import { FormOmittedProps, getFieldStatus } from "../../utils/FormUtils";
|
|
6
|
-
import moment, { Moment } from "moment";
|
|
7
|
-
|
|
8
|
-
export interface FormDatePickerProps extends Omit<DatePickerProps<Moment>, FormOmittedProps> {
|
|
9
|
-
textFieldProps?: TextFieldProps;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const FormDatePicker: FC<FormDatePickerProps> = (props) => {
|
|
13
|
-
const field = useFieldContext<string | null | undefined>();
|
|
14
|
-
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<DatePicker
|
|
18
|
-
name={field.name}
|
|
19
|
-
value={field.state.value ? moment(field.state.value) : null}
|
|
20
|
-
onChange={(value) => field.handleChange(value ? value.format() : null)}
|
|
21
|
-
slotProps={{
|
|
22
|
-
textField: {
|
|
23
|
-
onBlur: field.handleBlur,
|
|
24
|
-
error: isTouched && hasError,
|
|
25
|
-
helperText: isTouched && helperText,
|
|
26
|
-
...props.textFieldProps
|
|
27
|
-
},
|
|
28
|
-
...props.slotProps
|
|
29
|
-
}}
|
|
30
|
-
aria-label={field.name}
|
|
31
|
-
{...props}
|
|
32
|
-
/>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { TextFieldProps } from "@mui/material";
|
|
2
|
-
import { DateTimePicker, DateTimePickerProps } from "@mui/x-date-pickers-pro";
|
|
3
|
-
import { FC } from "react";
|
|
4
|
-
import { useFieldContext } from "../../hooks/FormHooks";
|
|
5
|
-
import { FormOmittedProps, getFieldStatus } from "../../utils/FormUtils";
|
|
6
|
-
import moment, { Moment } from "moment";
|
|
7
|
-
|
|
8
|
-
export interface FormDateTimePickerProps extends Omit<DateTimePickerProps<Moment>, FormOmittedProps> {
|
|
9
|
-
textFieldProps?: TextFieldProps;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const FormDateTimePicker: FC<FormDateTimePickerProps> = (props) => {
|
|
13
|
-
const field = useFieldContext<string | null | undefined>();
|
|
14
|
-
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<DateTimePicker
|
|
18
|
-
name={field.name}
|
|
19
|
-
value={field.state.value ? moment(field.state.value) : null}
|
|
20
|
-
onChange={(value) => field.handleChange(value ? value.format() : null)}
|
|
21
|
-
slotProps={{
|
|
22
|
-
textField: {
|
|
23
|
-
onBlur: field.handleBlur,
|
|
24
|
-
error: isTouched && hasError,
|
|
25
|
-
helperText: isTouched && helperText,
|
|
26
|
-
...props.textFieldProps,
|
|
27
|
-
},
|
|
28
|
-
...props.slotProps
|
|
29
|
-
}}
|
|
30
|
-
aria-label={field.name}
|
|
31
|
-
{...props}
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { TextField, TextFieldProps } from '@mui/material';
|
|
2
|
-
import { FC } from 'react';
|
|
3
|
-
import { NumericFormat } from 'react-number-format';
|
|
4
|
-
import { useFieldContext } from "../../hooks/FormHooks";
|
|
5
|
-
import { FormOmittedProps, getFieldStatus } from "../../utils/FormUtils";
|
|
6
|
-
import { NumericFormatProps, InputAttributes } from 'react-number-format/types/types';
|
|
7
|
-
|
|
8
|
-
interface FormTextFieldProps extends Omit<TextFieldProps, FormOmittedProps> { }
|
|
9
|
-
|
|
10
|
-
export interface FormNumberFieldProps extends FormTextFieldProps {
|
|
11
|
-
defaultValue?: number | null;
|
|
12
|
-
options?: Omit<NumericFormatProps<InputAttributes>, "customInput" | "onValueChange" | keyof InputAttributes>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const FormNumberField: FC<FormNumberFieldProps> = ({ options, ...props }) => {
|
|
16
|
-
const field = useFieldContext<number | null | undefined>();
|
|
17
|
-
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<NumericFormat
|
|
21
|
-
customInput={TextField}
|
|
22
|
-
name={field.name}
|
|
23
|
-
value={field.state.value ?? ''}
|
|
24
|
-
onValueChange={({ floatValue }) => field.handleChange(floatValue)}
|
|
25
|
-
onBlur={field.handleBlur}
|
|
26
|
-
error={isTouched && hasError}
|
|
27
|
-
helperText={isTouched && helperText}
|
|
28
|
-
aria-label={field.name}
|
|
29
|
-
{...props}
|
|
30
|
-
{...options}
|
|
31
|
-
/>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { FormControl, FormControlLabel, FormHelperText, FormLabel, Radio, RadioGroup, RadioGroupProps } from "@mui/material";
|
|
2
|
-
import { FC } from "react";
|
|
3
|
-
import { useFieldContext } from "../../hooks/FormHooks";
|
|
4
|
-
import { FormOmittedProps, getFieldStatus } from "../../utils/FormUtils";
|
|
5
|
-
|
|
6
|
-
interface Option {
|
|
7
|
-
label: string;
|
|
8
|
-
value: string | number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface FormRadioGroupProps extends Omit<RadioGroupProps, FormOmittedProps> {
|
|
12
|
-
label?: string;
|
|
13
|
-
options: Option[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const FormRadioGroup: FC<FormRadioGroupProps> = ({ label, options, ...props }) => {
|
|
17
|
-
const field = useFieldContext<string | number | null | undefined>();
|
|
18
|
-
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<FormControl component="fieldset">
|
|
22
|
-
{label && <FormLabel component="legend">{label}</FormLabel>}
|
|
23
|
-
<RadioGroup
|
|
24
|
-
name={field.name}
|
|
25
|
-
value={field.state.value ?? ""}
|
|
26
|
-
onChange={(e) => field.handleChange(e.target.value)}
|
|
27
|
-
onBlur={field.handleBlur}
|
|
28
|
-
aria-label={field.name}
|
|
29
|
-
{...props}
|
|
30
|
-
>
|
|
31
|
-
{options.map((option) => (
|
|
32
|
-
<FormControlLabel
|
|
33
|
-
key={option.value}
|
|
34
|
-
value={option.value}
|
|
35
|
-
control={<Radio />}
|
|
36
|
-
label={option.label}
|
|
37
|
-
/>
|
|
38
|
-
))}
|
|
39
|
-
</RadioGroup>
|
|
40
|
-
{isTouched && hasError && <FormHelperText error={hasError}>{helperText}</FormHelperText>}
|
|
41
|
-
</FormControl>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { FormControl, FormHelperText, FormLabel, Slider, SliderProps } from "@mui/material";
|
|
2
|
-
import { FC } from "react";
|
|
3
|
-
import { useFieldContext } from "../../hooks/FormHooks";
|
|
4
|
-
import { FormOmittedProps, getFieldStatus } from "../../utils/FormUtils";
|
|
5
|
-
|
|
6
|
-
export interface FormSliderProps extends Omit<SliderProps, FormOmittedProps> {
|
|
7
|
-
label?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const FormSlider: FC<FormSliderProps> = ({ label, ...props }) => {
|
|
11
|
-
const field = useFieldContext<number | null | undefined>();
|
|
12
|
-
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<FormControl component="fieldset">
|
|
16
|
-
{label && <FormLabel>{label}</FormLabel>}
|
|
17
|
-
<Slider
|
|
18
|
-
name={field.name}
|
|
19
|
-
value={field.state.value ?? 0}
|
|
20
|
-
onChange={(_, value) => field.handleChange(Array.isArray(value) ? value[0] : value)}
|
|
21
|
-
onBlur={field.handleBlur}
|
|
22
|
-
aria-label={field.name}
|
|
23
|
-
{...props}
|
|
24
|
-
/>
|
|
25
|
-
{isTouched && hasError && <FormHelperText error={hasError}>{helperText}</FormHelperText>}
|
|
26
|
-
</FormControl>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Button, ButtonProps } from "@mui/material";
|
|
2
|
-
import { FC } from "react";
|
|
3
|
-
import { useFormContext } from "../../hooks/FormHooks";
|
|
4
|
-
|
|
5
|
-
export interface FormSubmitButtonProps extends Omit<ButtonProps, "loading" | "disabled" | "onClick"> { }
|
|
6
|
-
|
|
7
|
-
export const FormSubmitButton: FC<FormSubmitButtonProps> = (props) => {
|
|
8
|
-
const form = useFormContext();
|
|
9
|
-
|
|
10
|
-
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
11
|
-
e.preventDefault();
|
|
12
|
-
e.stopPropagation();
|
|
13
|
-
form.handleSubmit();
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<form.Subscribe selector={(state) => [state.canSubmit, state.isSubmitting]}>
|
|
18
|
-
{([canSubmit, isSubmitting]) => (
|
|
19
|
-
<Button
|
|
20
|
-
loading={isSubmitting}
|
|
21
|
-
disabled={!canSubmit}
|
|
22
|
-
onClick={handleClick}
|
|
23
|
-
aria-label="submit"
|
|
24
|
-
{...props}
|
|
25
|
-
/>
|
|
26
|
-
)}
|
|
27
|
-
</form.Subscribe>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { FormControl, FormControlLabel, FormHelperText, Switch, SwitchProps } from "@mui/material";
|
|
2
|
-
import { FC } from "react";
|
|
3
|
-
import { useFieldContext } from "../../hooks/FormHooks";
|
|
4
|
-
import { FormOmittedProps, getFieldStatus } from "../../utils/FormUtils";
|
|
5
|
-
|
|
6
|
-
export interface FormSwitchProps extends Omit<SwitchProps, FormOmittedProps> {
|
|
7
|
-
label?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const FormSwitch: FC<FormSwitchProps> = (props) => {
|
|
11
|
-
const field = useFieldContext<boolean | null | undefined>();
|
|
12
|
-
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<FormControl component="fieldset">
|
|
16
|
-
<FormControlLabel
|
|
17
|
-
control={
|
|
18
|
-
<Switch
|
|
19
|
-
name={field.name}
|
|
20
|
-
checked={Boolean(field.state.value)}
|
|
21
|
-
onChange={(e) => field.handleChange(e.target.checked)}
|
|
22
|
-
onBlur={field.handleBlur}
|
|
23
|
-
aria-label={field.name}
|
|
24
|
-
{...props}
|
|
25
|
-
/>
|
|
26
|
-
}
|
|
27
|
-
label={props.label ?? ""}
|
|
28
|
-
/>
|
|
29
|
-
{isTouched && hasError && <FormHelperText error={hasError}>{helperText}</FormHelperText>}
|
|
30
|
-
</FormControl>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { TextField, TextFieldProps } from "@mui/material";
|
|
2
|
-
import { FC } from "react";
|
|
3
|
-
import { useFieldContext } from "../../hooks/FormHooks";
|
|
4
|
-
import { FormOmittedProps, getFieldStatus } from "../../utils/FormUtils";
|
|
5
|
-
|
|
6
|
-
export interface FormTextFieldProps extends Omit<TextFieldProps, FormOmittedProps> {
|
|
7
|
-
type?: "color" | "email" | "password" | "search" | "tel" | "text" | "url"
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const FormTextField: FC<FormTextFieldProps> = (props) => {
|
|
11
|
-
const field = useFieldContext<string | number | null | undefined>();
|
|
12
|
-
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<TextField
|
|
16
|
-
name={field.name}
|
|
17
|
-
value={field.state.value ?? ''}
|
|
18
|
-
onChange={e => field.handleChange(e.target.value)}
|
|
19
|
-
onBlur={field.handleBlur}
|
|
20
|
-
error={isTouched && hasError}
|
|
21
|
-
helperText={isTouched && helperText}
|
|
22
|
-
aria-label={field.name}
|
|
23
|
-
{...props}
|
|
24
|
-
/>
|
|
25
|
-
)
|
|
26
|
-
}
|