@codezee/sixtify-brahma 0.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.
- package/.github/workflows/deploy-storybook.yml +40 -0
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/.husky/pre-push +4 -0
- package/.lintstagedrc +5 -0
- package/.prettierignore +11 -0
- package/.prettierrc +22 -0
- package/.vscode/extensions.json +22 -0
- package/.vscode/settings.json +17 -0
- package/README.md +81 -0
- package/apps/docs/.eslintrc.cjs +4 -0
- package/apps/docs/.eslintrc.js +9 -0
- package/apps/docs/.storybook/main.ts +23 -0
- package/apps/docs/.storybook/preview.tsx +27 -0
- package/apps/docs/next-env.d.ts +5 -0
- package/apps/docs/next.config.mjs +4 -0
- package/apps/docs/package.json +38 -0
- package/apps/docs/public/globals.css +25 -0
- package/apps/docs/stories/AgGrid/AgGrid.stories.tsx +69 -0
- package/apps/docs/stories/AppBar/AppBar.stories.tsx +39 -0
- package/apps/docs/stories/Breadcrumbs/Breadcrumbs.stories.tsx +37 -0
- package/apps/docs/stories/Button/ButtonGroup.stories.tsx +99 -0
- package/apps/docs/stories/Button/button.stories.tsx +99 -0
- package/apps/docs/stories/Card/AttendanceCard.stories.tsx +37 -0
- package/apps/docs/stories/Card/Card.stories.tsx +39 -0
- package/apps/docs/stories/Charts/PieChart.stories.tsx +264 -0
- package/apps/docs/stories/Chips/Chip.stories.tsx +141 -0
- package/apps/docs/stories/Chips/ChipWithBorder.stories.tsx +18 -0
- package/apps/docs/stories/Chips/FilterPill.stories.tsx +24 -0
- package/apps/docs/stories/Color/Color.stories.tsx +14 -0
- package/apps/docs/stories/Dialog/ButtomDialog.stories.tsx +47 -0
- package/apps/docs/stories/Dialog/DeleteDialog.stories.tsx +31 -0
- package/apps/docs/stories/Dialog/Dialog.stories.tsx +47 -0
- package/apps/docs/stories/Drawer/Drawer.stories.tsx +94 -0
- package/apps/docs/stories/FilterList/FilterList.stories.tsx +88 -0
- package/apps/docs/stories/FilterList/FilterListV2.stories.tsx +92 -0
- package/apps/docs/stories/FormFields/AutoComplete.stories.tsx +87 -0
- package/apps/docs/stories/FormFields/CheckBox.stories.tsx +61 -0
- package/apps/docs/stories/FormFields/DatePicker.stories.tsx +98 -0
- package/apps/docs/stories/FormFields/DateRangePicker.stories.tsx +37 -0
- package/apps/docs/stories/FormFields/FileUpload.stories.tsx +83 -0
- package/apps/docs/stories/FormFields/ImageUpload.stories.tsx +69 -0
- package/apps/docs/stories/FormFields/ListItemButton.stories.tsx +59 -0
- package/apps/docs/stories/FormFields/RadioGroupField.stories.tsx +170 -0
- package/apps/docs/stories/FormFields/SearchField.stories.tsx +72 -0
- package/apps/docs/stories/FormFields/TextField.stories.tsx +111 -0
- package/apps/docs/stories/FormFields/TimeField.stories.tsx +82 -0
- package/apps/docs/stories/FormFields/TimePicker.stories.tsx +82 -0
- package/apps/docs/stories/Indicator/Indicator.stories.tsx +33 -0
- package/apps/docs/stories/Indicator/SeverityIndicator.stories.tsx +27 -0
- package/apps/docs/stories/Layouts/FormRow.stories.tsx +45 -0
- package/apps/docs/stories/PadBox/PadBox.stories.tsx +49 -0
- package/apps/docs/stories/Stepper/Stepper.stories.tsx +75 -0
- package/apps/docs/stories/Stepper/StepperV2.stories.tsx +44 -0
- package/apps/docs/stories/Timeline/AttendanceStatus.stories.tsx +29 -0
- package/apps/docs/stories/Timeline/Timeline.stories.tsx +38 -0
- package/apps/docs/stories/Tooltip/Tooltip.stories.tsx +30 -0
- package/apps/docs/stories/UserProfileMenu/UserProfileMenu.stories.tsx +112 -0
- package/apps/docs/tsconfig.json +19 -0
- package/commitlint.config.cjs +6 -0
- package/index.ts +1 -0
- package/package.json +74 -0
- package/packages/eslint-config/README.md +3 -0
- package/packages/eslint-config/library.js +88 -0
- package/packages/eslint-config/next.js +85 -0
- package/packages/eslint-config/package.json +19 -0
- package/packages/eslint-config/react-internal.js +89 -0
- package/packages/shared-components/.eslintrc.js +10 -0
- package/packages/shared-components/package.json +22 -0
- package/packages/shared-components/src/Actions/AddAction.tsx +13 -0
- package/packages/shared-components/src/Actions/CalendarAction.tsx +13 -0
- package/packages/shared-components/src/Actions/DeleteAction.tsx +13 -0
- package/packages/shared-components/src/Actions/DownloadAction.tsx +13 -0
- package/packages/shared-components/src/Actions/EditAction.tsx +13 -0
- package/packages/shared-components/src/Actions/HistoryAction.tsx +13 -0
- package/packages/shared-components/src/Actions/index.ts +6 -0
- package/packages/shared-components/src/AgGrid/ActionCell/ActionCell.tsx +55 -0
- package/packages/shared-components/src/AgGrid/ActionCell/Popover.tsx +32 -0
- package/packages/shared-components/src/AgGrid/AgGrid.tsx +87 -0
- package/packages/shared-components/src/AgGrid/LoadingCell.tsx +5 -0
- package/packages/shared-components/src/AgGrid/index.ts +3 -0
- package/packages/shared-components/src/AppBar/AppBar.styled.tsx +25 -0
- package/packages/shared-components/src/AppBar/AppBar.tsx +20 -0
- package/packages/shared-components/src/AppBar/index.ts +1 -0
- package/packages/shared-components/src/Breadcrumbs/Breadcrumbs.tsx +76 -0
- package/packages/shared-components/src/Breadcrumbs/index.ts +1 -0
- package/packages/shared-components/src/Button/ActionButton.tsx +38 -0
- package/packages/shared-components/src/Button/Button.tsx +19 -0
- package/packages/shared-components/src/Button/ButtonGroup.tsx +37 -0
- package/packages/shared-components/src/Button/index.ts +3 -0
- package/packages/shared-components/src/Card/AttendanceCard.tsx +51 -0
- package/packages/shared-components/src/Card/Card.tsx +34 -0
- package/packages/shared-components/src/Card/CardItem/CardItem.tsx +33 -0
- package/packages/shared-components/src/Card/CardItem/CardItemValue.tsx +98 -0
- package/packages/shared-components/src/Card/CardItem/index.ts +2 -0
- package/packages/shared-components/src/Card/ProfileCard/ProfileCard.tsx +40 -0
- package/packages/shared-components/src/Card/ProfileCard/ProfileCardItem/ProfileCardBody.tsx +53 -0
- package/packages/shared-components/src/Card/ProfileCard/ProfileCardItem/ProfileCardHeader.tsx +96 -0
- package/packages/shared-components/src/Card/index.ts +6 -0
- package/packages/shared-components/src/Charts/PieChart.tsx +69 -0
- package/packages/shared-components/src/Charts/index.ts +1 -0
- package/packages/shared-components/src/Chips/Chip.tsx +26 -0
- package/packages/shared-components/src/Chips/ChipWithBorder.tsx +39 -0
- package/packages/shared-components/src/Chips/FilterPill.tsx +47 -0
- package/packages/shared-components/src/Chips/index.ts +3 -0
- package/packages/shared-components/src/Dialog/BottomDialog.styled.tsx +28 -0
- package/packages/shared-components/src/Dialog/BottomDialog.tsx +37 -0
- package/packages/shared-components/src/Dialog/DeleteDialog.tsx +48 -0
- package/packages/shared-components/src/Dialog/Dialog.tsx +61 -0
- package/packages/shared-components/src/Dialog/index.ts +3 -0
- package/packages/shared-components/src/Drawer/Bullet.tsx +12 -0
- package/packages/shared-components/src/Drawer/CloseDrawer/CloseDrawerMenuItem.tsx +50 -0
- package/packages/shared-components/src/Drawer/CloseDrawer/CloseDrawerMenuItemList.tsx +105 -0
- package/packages/shared-components/src/Drawer/CloseDrawer/CloseDrawerSubMenuItemList.tsx +125 -0
- package/packages/shared-components/src/Drawer/CloseDrawer/MenuItem.tsx +0 -0
- package/packages/shared-components/src/Drawer/CloseDrawer/Popover.tsx +45 -0
- package/packages/shared-components/src/Drawer/CloseDrawer/Popper.tsx +43 -0
- package/packages/shared-components/src/Drawer/Drawer.styled.tsx +51 -0
- package/packages/shared-components/src/Drawer/Drawer.tsx +55 -0
- package/packages/shared-components/src/Drawer/MenuItem.tsx +69 -0
- package/packages/shared-components/src/Drawer/OpenDrawer/OpenDrawerCollapse.tsx +13 -0
- package/packages/shared-components/src/Drawer/OpenDrawer/OpenDrawerMenuItem.tsx +46 -0
- package/packages/shared-components/src/Drawer/OpenDrawer/OpenDrawerMenuItemList.tsx +249 -0
- package/packages/shared-components/src/Drawer/index.ts +1 -0
- package/packages/shared-components/src/FilterList/FilterList.tsx +172 -0
- package/packages/shared-components/src/FilterList/FilterListV2.tsx +504 -0
- package/packages/shared-components/src/FilterList/FilterPopup.tsx +148 -0
- package/packages/shared-components/src/FilterList/FilterPopupWrapper.tsx +113 -0
- package/packages/shared-components/src/FilterList/FilterTypeWrapper.tsx +58 -0
- package/packages/shared-components/src/FilterList/getFormData.ts +29 -0
- package/packages/shared-components/src/FilterList/index.ts +3 -0
- package/packages/shared-components/src/FormFields/Autocomplete/Autocomplete.tsx +428 -0
- package/packages/shared-components/src/FormFields/Autocomplete/Skeleton.tsx +26 -0
- package/packages/shared-components/src/FormFields/Autocomplete/index.ts +1 -0
- package/packages/shared-components/src/FormFields/CheckBox/CheckBox.styled.tsx +67 -0
- package/packages/shared-components/src/FormFields/CheckBox/CheckBox.tsx +44 -0
- package/packages/shared-components/src/FormFields/CheckBox/Skeleton.tsx +12 -0
- package/packages/shared-components/src/FormFields/CheckBox/index.ts +1 -0
- package/packages/shared-components/src/FormFields/DatePicker/DatePicker.tsx +206 -0
- package/packages/shared-components/src/FormFields/DatePicker/Skeleton.tsx +21 -0
- package/packages/shared-components/src/FormFields/DatePicker/index.ts +1 -0
- package/packages/shared-components/src/FormFields/DateRangePicker/DateRangePicker.tsx +96 -0
- package/packages/shared-components/src/FormFields/DateRangePicker/Skeleton.tsx +38 -0
- package/packages/shared-components/src/FormFields/DateRangePicker/index.ts +1 -0
- package/packages/shared-components/src/FormFields/DateTimePicker/DateTimePicker.tsx +245 -0
- package/packages/shared-components/src/FormFields/DateTimePicker/Skeleton.tsx +24 -0
- package/packages/shared-components/src/FormFields/DateTimePicker/index.ts +1 -0
- package/packages/shared-components/src/FormFields/FileUpload/FileUpload.styled.tsx +22 -0
- package/packages/shared-components/src/FormFields/FileUpload/FileUpload.tsx +197 -0
- package/packages/shared-components/src/FormFields/FileUpload/Skeleton.tsx +21 -0
- package/packages/shared-components/src/FormFields/FileUpload/UploadedFileName.tsx +27 -0
- package/packages/shared-components/src/FormFields/FileUpload/index.ts +1 -0
- package/packages/shared-components/src/FormFields/ImageUpload/ImageUpload.styled.tsx +16 -0
- package/packages/shared-components/src/FormFields/ImageUpload/ImageUpload.tsx +181 -0
- package/packages/shared-components/src/FormFields/ImageUpload/ImageUploadView.tsx +65 -0
- package/packages/shared-components/src/FormFields/ImageUpload/PhotoCaptureDialog.tsx +74 -0
- package/packages/shared-components/src/FormFields/ImageUpload/Skeleton.tsx +31 -0
- package/packages/shared-components/src/FormFields/ImageUpload/index.ts +2 -0
- package/packages/shared-components/src/FormFields/ListItemButton/ListItemButton.styled.tsx +22 -0
- package/packages/shared-components/src/FormFields/ListItemButton/ListItemButton.tsx +37 -0
- package/packages/shared-components/src/FormFields/ListItemButton/index.ts +1 -0
- package/packages/shared-components/src/FormFields/PasswordField/PasswordField.tsx +50 -0
- package/packages/shared-components/src/FormFields/PasswordField/index.ts +1 -0
- package/packages/shared-components/src/FormFields/RadioGroupField/RadioGroupField.tsx +105 -0
- package/packages/shared-components/src/FormFields/RadioGroupField/Skeleton.tsx +26 -0
- package/packages/shared-components/src/FormFields/RadioGroupField/index.ts +1 -0
- package/packages/shared-components/src/FormFields/SearchField/SearchField.tsx +21 -0
- package/packages/shared-components/src/FormFields/SearchField/index.ts +1 -0
- package/packages/shared-components/src/FormFields/Switch/Skeleton.tsx +12 -0
- package/packages/shared-components/src/FormFields/Switch/Switch.tsx +33 -0
- package/packages/shared-components/src/FormFields/Switch/index.ts +1 -0
- package/packages/shared-components/src/FormFields/TextField/Skeleton.tsx +26 -0
- package/packages/shared-components/src/FormFields/TextField/TextField.tsx +92 -0
- package/packages/shared-components/src/FormFields/TextField/index.ts +1 -0
- package/packages/shared-components/src/FormFields/TimeField/Skeleton.tsx +24 -0
- package/packages/shared-components/src/FormFields/TimeField/TimeField.tsx +120 -0
- package/packages/shared-components/src/FormFields/TimeField/index.ts +1 -0
- package/packages/shared-components/src/FormFields/TimePicker/Skeleton.tsx +24 -0
- package/packages/shared-components/src/FormFields/TimePicker/TimePicker.tsx +162 -0
- package/packages/shared-components/src/FormFields/TimePicker/index.ts +1 -0
- package/packages/shared-components/src/FormFields/index.ts +13 -0
- package/packages/shared-components/src/Indicator/Indicator.tsx +17 -0
- package/packages/shared-components/src/Indicator/SeverityIndicator.tsx +34 -0
- package/packages/shared-components/src/Indicator/index.ts +2 -0
- package/packages/shared-components/src/Layouts/FormContainer.tsx +6 -0
- package/packages/shared-components/src/Layouts/FormRow/FormRow.styled.tsx +39 -0
- package/packages/shared-components/src/Layouts/FormRow/FormRow.tsx +20 -0
- package/packages/shared-components/src/Layouts/FormRow/index.ts +1 -0
- package/packages/shared-components/src/Layouts/FormSection.tsx +22 -0
- package/packages/shared-components/src/Layouts/index.ts +3 -0
- package/packages/shared-components/src/Loader/FacebookCircularProgress.tsx +41 -0
- package/packages/shared-components/src/Loader/index.ts +1 -0
- package/packages/shared-components/src/PadBox/PadBox.tsx +21 -0
- package/packages/shared-components/src/PadBox/index.ts +1 -0
- package/packages/shared-components/src/Stepper/Stepper.tsx +54 -0
- package/packages/shared-components/src/Stepper/StepperV2.tsx +115 -0
- package/packages/shared-components/src/Stepper/StepperV3.tsx +72 -0
- package/packages/shared-components/src/Stepper/index.ts +3 -0
- package/packages/shared-components/src/Svgs/AppLogo/AppLogoMedium.tsx +65 -0
- package/packages/shared-components/src/Svgs/AppLogo/AppLogoSmall.tsx +48 -0
- package/packages/shared-components/src/Svgs/ArrowUp.tsx +11 -0
- package/packages/shared-components/src/Svgs/Company/CompanyBanner.tsx +480 -0
- package/packages/shared-components/src/Svgs/Company/index.ts +1 -0
- package/packages/shared-components/src/Svgs/Drawer/SettingIcon.tsx +51 -0
- package/packages/shared-components/src/Svgs/Drawer/SvgsEmployees.tsx +25 -0
- package/packages/shared-components/src/Svgs/Drawer/SvgsOrganization.tsx +36 -0
- package/packages/shared-components/src/Svgs/Drawer/SvgsTransaction.tsx +79 -0
- package/packages/shared-components/src/Svgs/Drawer/index.ts +4 -0
- package/packages/shared-components/src/Svgs/FormAction.tsx +118 -0
- package/packages/shared-components/src/Svgs/LogoIcon.tsx +74 -0
- package/packages/shared-components/src/Svgs/SvgAdd.tsx +28 -0
- package/packages/shared-components/src/Svgs/SvgCalendar.tsx +89 -0
- package/packages/shared-components/src/Svgs/SvgDelete.tsx +55 -0
- package/packages/shared-components/src/Svgs/SvgDownload.tsx +20 -0
- package/packages/shared-components/src/Svgs/SvgFilterList.tsx +19 -0
- package/packages/shared-components/src/Svgs/SvgNoLogo.tsx +66 -0
- package/packages/shared-components/src/Svgs/SvgNoSign.tsx +28 -0
- package/packages/shared-components/src/Svgs/SvgsDrop.tsx +44 -0
- package/packages/shared-components/src/Svgs/SvgsEdit.tsx +42 -0
- package/packages/shared-components/src/Svgs/SvgsHistory.tsx +40 -0
- package/packages/shared-components/src/Svgs/SvgsHome.tsx +16 -0
- package/packages/shared-components/src/Svgs/SvgsIndicator.tsx +20 -0
- package/packages/shared-components/src/Svgs/index.ts +12 -0
- package/packages/shared-components/src/Tab/Skeleton.tsx +15 -0
- package/packages/shared-components/src/Tab/Tabs.tsx +64 -0
- package/packages/shared-components/src/Tab/index.ts +1 -0
- package/packages/shared-components/src/Timeline/AttendanceStatus.tsx +56 -0
- package/packages/shared-components/src/Timeline/Timeline.tsx +171 -0
- package/packages/shared-components/src/Timeline/TimelineTrackSegments.tsx +121 -0
- package/packages/shared-components/src/Timeline/index.ts +2 -0
- package/packages/shared-components/src/Toast/Toast.tsx +59 -0
- package/packages/shared-components/src/Toast/ToastBody.tsx +26 -0
- package/packages/shared-components/src/Toast/ToastFooterLink.tsx +19 -0
- package/packages/shared-components/src/Toast/Toaster.styled.tsx +76 -0
- package/packages/shared-components/src/Toast/Toaster.tsx +21 -0
- package/packages/shared-components/src/Toast/index.ts +3 -0
- package/packages/shared-components/src/Toast/toasts.tsx +28 -0
- package/packages/shared-components/src/Toast/types.ts +13 -0
- package/packages/shared-components/src/Tooltip/Tooltip.tsx +36 -0
- package/packages/shared-components/src/Tooltip/index.ts +1 -0
- package/packages/shared-components/src/UserProfileMenu/UserProfileMenu.styled.tsx +37 -0
- package/packages/shared-components/src/UserProfileMenu/UserProfileMenu.tsx +107 -0
- package/packages/shared-components/src/UserProfileMenu/index.ts +1 -0
- package/packages/shared-components/src/index.ts +24 -0
- package/packages/shared-components/src/utils/colorVariant.ts +142 -0
- package/packages/shared-components/src/utils/date.ts +11 -0
- package/packages/shared-components/src/utils/file.ts +20 -0
- package/packages/shared-components/src/utils/fileSizeValidate.ts +5 -0
- package/packages/shared-components/src/utils/index.ts +5 -0
- package/packages/shared-components/src/utils/theme/colorPalette.ts +110 -0
- package/packages/shared-components/src/utils/theme/colorPaletteUI.tsx +44 -0
- package/packages/shared-components/src/utils/theme/paletteDark.ts +10 -0
- package/packages/shared-components/src/utils/theme/paletteLight.ts +31 -0
- package/packages/shared-components/src/utils/theme/theme.ts +289 -0
- package/packages/shared-components/src/utils/theme/types.ts +18 -0
- package/packages/shared-components/src/utils/theme/typography.ts +52 -0
- package/packages/shared-components/src/utils/urlToNestedObject.ts +9 -0
- package/packages/shared-components/tsconfig.json +8 -0
- package/packages/shared-components/tsconfig.lint.json +8 -0
- package/packages/shared-components/turbo/generators/config.ts +33 -0
- package/packages/shared-components/turbo/generators/templates/component.hbs +8 -0
- package/packages/typescript-config/base.json +20 -0
- package/packages/typescript-config/nextjs.json +13 -0
- package/packages/typescript-config/package.json +9 -0
- package/packages/typescript-config/react-library.json +8 -0
- package/pnpm-workspace.yaml +3 -0
- package/turbo.json +44 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { Delete as DeleteIcon, Edit as EditIcon } from "@mui/icons-material";
|
|
2
|
+
import CameraAltOutlinedIcon from "@mui/icons-material/CameraAltOutlined";
|
|
3
|
+
import PersonAddAltIcon from "@mui/icons-material/PersonAddAlt";
|
|
4
|
+
import { Box, IconButton, Stack, Typography, useTheme } from "@mui/material";
|
|
5
|
+
import { useRef, useState } from "react";
|
|
6
|
+
import { Button } from "../../Button";
|
|
7
|
+
import { PadBox } from "../../PadBox";
|
|
8
|
+
import { DarkBackgroundContainer } from "./ImageUpload.styled";
|
|
9
|
+
import { PhotoCaptureDialog } from "./PhotoCaptureDialog";
|
|
10
|
+
import { Skeleton } from "./Skeleton";
|
|
11
|
+
|
|
12
|
+
export type ImageUploadProps = Readonly<{
|
|
13
|
+
onDelete: () => void;
|
|
14
|
+
onChange: (file: File[]) => void;
|
|
15
|
+
variant?: "square" | "circle";
|
|
16
|
+
isUploading?: boolean;
|
|
17
|
+
label?: string;
|
|
18
|
+
subTitle?: string;
|
|
19
|
+
defaultValue?: string;
|
|
20
|
+
isCapture?: boolean;
|
|
21
|
+
loading?: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
|
|
24
|
+
export function ImageUpload({
|
|
25
|
+
variant = "square",
|
|
26
|
+
isUploading = false,
|
|
27
|
+
defaultValue = "",
|
|
28
|
+
onDelete,
|
|
29
|
+
onChange,
|
|
30
|
+
label,
|
|
31
|
+
isCapture = false,
|
|
32
|
+
loading = false,
|
|
33
|
+
subTitle = "PNG, JPEG under 5 MB",
|
|
34
|
+
}: ImageUploadProps) {
|
|
35
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
36
|
+
|
|
37
|
+
const [hover, setHover] = useState(false);
|
|
38
|
+
|
|
39
|
+
const [isOpenCaptureModal, setIsOpenCaptureModal] = useState(false);
|
|
40
|
+
|
|
41
|
+
const theme = useTheme();
|
|
42
|
+
|
|
43
|
+
const { butterflyBlue, iron } = theme.palette.app.color;
|
|
44
|
+
|
|
45
|
+
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
46
|
+
if (event.target.files) {
|
|
47
|
+
const files = Array.from(event.target.files);
|
|
48
|
+
|
|
49
|
+
onChange(files);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const handleFileRemove = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
54
|
+
event.stopPropagation();
|
|
55
|
+
onDelete();
|
|
56
|
+
|
|
57
|
+
if (inputRef.current) {
|
|
58
|
+
inputRef.current.value = "";
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (loading) {
|
|
63
|
+
return <Skeleton />;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<>
|
|
68
|
+
<Stack gap="20px" direction="row" alignItems="center">
|
|
69
|
+
<Box
|
|
70
|
+
onClick={() => !defaultValue && inputRef.current?.click()}
|
|
71
|
+
onMouseEnter={() => setHover(true)}
|
|
72
|
+
onMouseLeave={() => setHover(false)}
|
|
73
|
+
sx={{
|
|
74
|
+
height: "120px",
|
|
75
|
+
width: "120px",
|
|
76
|
+
position: "relative",
|
|
77
|
+
overflow: "hidden",
|
|
78
|
+
border: defaultValue
|
|
79
|
+
? `2px solid ${butterflyBlue[900]}`
|
|
80
|
+
: `2px dashed ${theme.palette.grey[400]}`,
|
|
81
|
+
cursor: "pointer",
|
|
82
|
+
borderRadius: "10px",
|
|
83
|
+
"& img": {
|
|
84
|
+
borderRadius: "10px",
|
|
85
|
+
},
|
|
86
|
+
":hover": {
|
|
87
|
+
border: `2px dashed ${butterflyBlue[900]}`,
|
|
88
|
+
},
|
|
89
|
+
...(variant === "circle"
|
|
90
|
+
? {
|
|
91
|
+
borderRadius: "50%",
|
|
92
|
+
"& img": {
|
|
93
|
+
borderRadius: "50%",
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
: {}),
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
<input
|
|
100
|
+
type="file"
|
|
101
|
+
ref={inputRef}
|
|
102
|
+
onChange={handleFileChange}
|
|
103
|
+
style={{ display: "none" }}
|
|
104
|
+
accept="image/png, image/jpeg"
|
|
105
|
+
/>
|
|
106
|
+
|
|
107
|
+
{hover && !!defaultValue && (
|
|
108
|
+
<DarkBackgroundContainer>
|
|
109
|
+
<IconButton onClick={() => inputRef.current?.click()}>
|
|
110
|
+
<EditIcon sx={{ color: "white" }} />
|
|
111
|
+
</IconButton>
|
|
112
|
+
<IconButton onClick={handleFileRemove}>
|
|
113
|
+
<DeleteIcon sx={{ color: "white" }} />
|
|
114
|
+
</IconButton>
|
|
115
|
+
</DarkBackgroundContainer>
|
|
116
|
+
)}
|
|
117
|
+
|
|
118
|
+
{isUploading && (
|
|
119
|
+
<DarkBackgroundContainer>
|
|
120
|
+
<Typography color={iron[600]}>Processing...</Typography>
|
|
121
|
+
</DarkBackgroundContainer>
|
|
122
|
+
)}
|
|
123
|
+
|
|
124
|
+
{defaultValue ? (
|
|
125
|
+
<PadBox padding={{ padding: "2px" }}>
|
|
126
|
+
<img
|
|
127
|
+
alt=""
|
|
128
|
+
src={defaultValue}
|
|
129
|
+
style={{
|
|
130
|
+
width: "100%",
|
|
131
|
+
height: "100%",
|
|
132
|
+
objectFit: "cover",
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
</PadBox>
|
|
136
|
+
) : (
|
|
137
|
+
<Stack
|
|
138
|
+
justifyContent="center"
|
|
139
|
+
alignItems="center"
|
|
140
|
+
sx={{ height: "100%" }}
|
|
141
|
+
>
|
|
142
|
+
<PersonAddAltIcon />
|
|
143
|
+
</Stack>
|
|
144
|
+
)}
|
|
145
|
+
</Box>
|
|
146
|
+
|
|
147
|
+
<Stack>
|
|
148
|
+
<Typography variant="subtitle1" fontWeight={500}>
|
|
149
|
+
{label}
|
|
150
|
+
</Typography>
|
|
151
|
+
|
|
152
|
+
<Typography variant="caption" color={iron[800]}>
|
|
153
|
+
{subTitle}
|
|
154
|
+
</Typography>
|
|
155
|
+
</Stack>
|
|
156
|
+
|
|
157
|
+
{isCapture && (
|
|
158
|
+
<Button
|
|
159
|
+
onClick={() => setIsOpenCaptureModal(true)}
|
|
160
|
+
variant="outlined"
|
|
161
|
+
>
|
|
162
|
+
<Stack gap="10px" direction="row">
|
|
163
|
+
<CameraAltOutlinedIcon />
|
|
164
|
+
|
|
165
|
+
<Typography variant="body1">Capture photo</Typography>
|
|
166
|
+
</Stack>
|
|
167
|
+
</Button>
|
|
168
|
+
)}
|
|
169
|
+
</Stack>
|
|
170
|
+
|
|
171
|
+
{isOpenCaptureModal && (
|
|
172
|
+
<PhotoCaptureDialog
|
|
173
|
+
onChange={onChange}
|
|
174
|
+
isUploading={isUploading}
|
|
175
|
+
open={isOpenCaptureModal}
|
|
176
|
+
onClose={() => setIsOpenCaptureModal(false)}
|
|
177
|
+
/>
|
|
178
|
+
)}
|
|
179
|
+
</>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Avatar, Box, Stack, useTheme } from "@mui/material";
|
|
2
|
+
import { PadBox } from "../../PadBox";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
|
|
5
|
+
export type ImageUploadViewProps = Readonly<{
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
variant: string;
|
|
8
|
+
}>;
|
|
9
|
+
export function ImageUploadView({
|
|
10
|
+
defaultValue,
|
|
11
|
+
variant,
|
|
12
|
+
}: ImageUploadViewProps) {
|
|
13
|
+
const theme = useTheme();
|
|
14
|
+
|
|
15
|
+
const { butterflyBlue } = theme.palette.app.color;
|
|
16
|
+
|
|
17
|
+
const [hasError, setHasError] = useState(false);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Box
|
|
21
|
+
sx={{
|
|
22
|
+
height: "120px",
|
|
23
|
+
minWidth: "120px",
|
|
24
|
+
maxWidth: "120px",
|
|
25
|
+
overflow: "hidden",
|
|
26
|
+
border: `2px solid ${butterflyBlue[900]}`,
|
|
27
|
+
borderRadius: "10px",
|
|
28
|
+
"& img": {
|
|
29
|
+
borderRadius: "10px",
|
|
30
|
+
},
|
|
31
|
+
...(variant === "circle"
|
|
32
|
+
? {
|
|
33
|
+
borderRadius: "50%",
|
|
34
|
+
"& img": {
|
|
35
|
+
borderRadius: "50%",
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
: {}),
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
{defaultValue && !hasError ? (
|
|
42
|
+
<PadBox padding={{ padding: "2px" }}>
|
|
43
|
+
<img
|
|
44
|
+
alt=""
|
|
45
|
+
src={defaultValue}
|
|
46
|
+
onError={() => setHasError(true)}
|
|
47
|
+
style={{
|
|
48
|
+
width: "100%",
|
|
49
|
+
height: "100%",
|
|
50
|
+
objectFit: "cover",
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
</PadBox>
|
|
54
|
+
) : (
|
|
55
|
+
<Stack
|
|
56
|
+
justifyContent="center"
|
|
57
|
+
alignItems="center"
|
|
58
|
+
sx={{ height: "100%" }}
|
|
59
|
+
>
|
|
60
|
+
<Avatar sx={{ width: "93%", height: "93%" }} />
|
|
61
|
+
</Stack>
|
|
62
|
+
)}
|
|
63
|
+
</Box>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Stack } from "@mui/material";
|
|
2
|
+
import { base64ToFile } from "file64";
|
|
3
|
+
import { useCallback, useRef } from "react";
|
|
4
|
+
import Webcam from "react-webcam";
|
|
5
|
+
import { Button } from "../../Button";
|
|
6
|
+
import { Dialog } from "../../Dialog";
|
|
7
|
+
import { toasts } from "../../Toast";
|
|
8
|
+
|
|
9
|
+
type PhotoCaptureDialogProps = {
|
|
10
|
+
open: boolean;
|
|
11
|
+
isUploading: boolean;
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
onChange: (file: File[]) => void;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const PhotoCaptureDialog = ({
|
|
17
|
+
open,
|
|
18
|
+
isUploading,
|
|
19
|
+
onClose,
|
|
20
|
+
onChange,
|
|
21
|
+
}: PhotoCaptureDialogProps) => {
|
|
22
|
+
const webcamRef = useRef<Webcam | null>(null);
|
|
23
|
+
|
|
24
|
+
const capture = useCallback(async () => {
|
|
25
|
+
if (webcamRef.current) {
|
|
26
|
+
const imageSrc = webcamRef.current.getScreenshot();
|
|
27
|
+
|
|
28
|
+
if (imageSrc) {
|
|
29
|
+
try {
|
|
30
|
+
const file = await base64ToFile(imageSrc, "image/jpeg");
|
|
31
|
+
|
|
32
|
+
onChange([file]);
|
|
33
|
+
|
|
34
|
+
onClose();
|
|
35
|
+
} catch (error) {
|
|
36
|
+
toasts.error({ title: `Failed to convert base64 to file:${error}` });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}, [webcamRef]);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Dialog
|
|
44
|
+
onClose={onClose}
|
|
45
|
+
open={open}
|
|
46
|
+
title="Photo Capture"
|
|
47
|
+
maxWidth="md"
|
|
48
|
+
actions={
|
|
49
|
+
<Stack direction="row" gap="5px">
|
|
50
|
+
<Button onClick={onClose} variant="outlined">
|
|
51
|
+
Cancel
|
|
52
|
+
</Button>
|
|
53
|
+
|
|
54
|
+
<Button
|
|
55
|
+
onClick={() => {
|
|
56
|
+
capture();
|
|
57
|
+
}}
|
|
58
|
+
loading={isUploading}
|
|
59
|
+
>
|
|
60
|
+
Save
|
|
61
|
+
</Button>
|
|
62
|
+
</Stack>
|
|
63
|
+
}
|
|
64
|
+
>
|
|
65
|
+
<Webcam
|
|
66
|
+
mirrored
|
|
67
|
+
ref={webcamRef}
|
|
68
|
+
screenshotFormat="image/jpeg"
|
|
69
|
+
width="835"
|
|
70
|
+
height="600"
|
|
71
|
+
/>
|
|
72
|
+
</Dialog>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Skeleton as MuiSkeleton, Stack } from "@mui/material";
|
|
2
|
+
|
|
3
|
+
export const Skeleton = () => {
|
|
4
|
+
return (
|
|
5
|
+
<Stack gap="20px" direction="row" alignItems="center">
|
|
6
|
+
<MuiSkeleton
|
|
7
|
+
width="120px"
|
|
8
|
+
height="120px"
|
|
9
|
+
sx={{
|
|
10
|
+
transform: "scale(1)",
|
|
11
|
+
}}
|
|
12
|
+
></MuiSkeleton>
|
|
13
|
+
<Stack gap="8px">
|
|
14
|
+
<MuiSkeleton
|
|
15
|
+
width={129}
|
|
16
|
+
height="24px"
|
|
17
|
+
sx={{
|
|
18
|
+
transform: "scale(1)",
|
|
19
|
+
}}
|
|
20
|
+
/>
|
|
21
|
+
<MuiSkeleton
|
|
22
|
+
width={129}
|
|
23
|
+
height="16px"
|
|
24
|
+
sx={{
|
|
25
|
+
transform: "scale(1)",
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
</Stack>
|
|
29
|
+
</Stack>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
styled,
|
|
3
|
+
ListItemButton as MuiListItemButton,
|
|
4
|
+
type ListItemButtonProps as MuiListItemButtonProps,
|
|
5
|
+
} from "@mui/material";
|
|
6
|
+
|
|
7
|
+
export const StyledListItemButton = styled(MuiListItemButton, {
|
|
8
|
+
shouldForwardProp: (prop) => prop !== "selected",
|
|
9
|
+
})<MuiListItemButtonProps & { selected?: boolean }>(({ theme, selected }) => ({
|
|
10
|
+
background: theme.palette.app.color.iron[600],
|
|
11
|
+
color: theme.palette.app.color.mirage[900],
|
|
12
|
+
borderRadius: "4px",
|
|
13
|
+
//TODO: Manish, Add a transition
|
|
14
|
+
border: `1px solid ${theme.palette.app.color.butterflyBlue[300]}`,
|
|
15
|
+
...(selected
|
|
16
|
+
? {
|
|
17
|
+
background: theme.palette.app.color.deepAqua[500],
|
|
18
|
+
color: theme.palette.app.color.mirage[900],
|
|
19
|
+
borderLeft: `6px solid ${theme.palette.app.color.butterflyBlue[900]}`,
|
|
20
|
+
}
|
|
21
|
+
: {}),
|
|
22
|
+
}));
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Stack,
|
|
3
|
+
type ListItemButtonProps as MuiListItemButtonProps,
|
|
4
|
+
} from "@mui/material";
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
import { Tooltip } from "../../Tooltip";
|
|
7
|
+
import { StyledListItemButton } from "./ListItemButton.styled";
|
|
8
|
+
|
|
9
|
+
export type ListItemButtonProps = MuiListItemButtonProps & {
|
|
10
|
+
label: string;
|
|
11
|
+
actions?: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function ListItemButton({
|
|
15
|
+
label,
|
|
16
|
+
selected,
|
|
17
|
+
actions,
|
|
18
|
+
...restListItemButtonProps
|
|
19
|
+
}: ListItemButtonProps) {
|
|
20
|
+
return (
|
|
21
|
+
<StyledListItemButton
|
|
22
|
+
selected={selected}
|
|
23
|
+
alignItems="flex-start"
|
|
24
|
+
{...restListItemButtonProps}
|
|
25
|
+
>
|
|
26
|
+
<Stack
|
|
27
|
+
width="100%"
|
|
28
|
+
flexDirection="row"
|
|
29
|
+
alignItems="center"
|
|
30
|
+
justifyContent="space-between"
|
|
31
|
+
>
|
|
32
|
+
<Tooltip toolTipLabel={label}>{label}</Tooltip>
|
|
33
|
+
{actions}
|
|
34
|
+
</Stack>
|
|
35
|
+
</StyledListItemButton>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ListItemButton";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { LockOutlined } from "@mui/icons-material";
|
|
2
|
+
import VisibilityOffOutlinedIcon from "@mui/icons-material/VisibilityOffOutlined";
|
|
3
|
+
import VisibilityOutlinedIcon from "@mui/icons-material/VisibilityOutlined";
|
|
4
|
+
import { IconButton, InputAdornment } from "@mui/material";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { type FieldValues } from "react-hook-form";
|
|
7
|
+
import { TextField, type TextFieldProps } from "../TextField";
|
|
8
|
+
|
|
9
|
+
type PasswordFieldProps<P extends FieldValues> = Readonly<
|
|
10
|
+
Omit<TextFieldProps<P>, "InputProps">
|
|
11
|
+
>;
|
|
12
|
+
|
|
13
|
+
export function PasswordField<P extends FieldValues>(
|
|
14
|
+
props: PasswordFieldProps<P>
|
|
15
|
+
) {
|
|
16
|
+
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
|
|
17
|
+
|
|
18
|
+
const togglePasswordVisibility = () => {
|
|
19
|
+
setIsPasswordVisible((prevState) => !prevState);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<TextField
|
|
24
|
+
type={isPasswordVisible ? "text" : "password"}
|
|
25
|
+
InputProps={{
|
|
26
|
+
startAdornment: (
|
|
27
|
+
<InputAdornment position="start">
|
|
28
|
+
<LockOutlined fontSize="small" />
|
|
29
|
+
</InputAdornment>
|
|
30
|
+
),
|
|
31
|
+
endAdornment: (
|
|
32
|
+
<InputAdornment position="end">
|
|
33
|
+
<IconButton
|
|
34
|
+
aria-label="toggle password visibility"
|
|
35
|
+
onClick={togglePasswordVisibility}
|
|
36
|
+
edge="end"
|
|
37
|
+
>
|
|
38
|
+
{isPasswordVisible ? (
|
|
39
|
+
<VisibilityOffOutlinedIcon fontSize="small" />
|
|
40
|
+
) : (
|
|
41
|
+
<VisibilityOutlinedIcon fontSize="small" />
|
|
42
|
+
)}
|
|
43
|
+
</IconButton>
|
|
44
|
+
</InputAdornment>
|
|
45
|
+
),
|
|
46
|
+
}}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./PasswordField";
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FormControlLabel,
|
|
3
|
+
InputLabel,
|
|
4
|
+
RadioGroup,
|
|
5
|
+
Stack,
|
|
6
|
+
Box,
|
|
7
|
+
type StackOwnProps,
|
|
8
|
+
type SxProps,
|
|
9
|
+
} from "@mui/material";
|
|
10
|
+
import Radio, { type RadioProps as MuiRadioProps } from "@mui/material/Radio";
|
|
11
|
+
import {
|
|
12
|
+
useController,
|
|
13
|
+
type ControllerRenderProps,
|
|
14
|
+
type FieldValues,
|
|
15
|
+
type UseControllerProps,
|
|
16
|
+
} from "react-hook-form";
|
|
17
|
+
import { Skeleton } from "./Skeleton";
|
|
18
|
+
import type { ReactNode } from "react";
|
|
19
|
+
|
|
20
|
+
type Options = {
|
|
21
|
+
values: boolean | string;
|
|
22
|
+
label?: ReactNode;
|
|
23
|
+
disabled: boolean;
|
|
24
|
+
direction?: StackOwnProps["direction"];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type RadioGroupFieldProps<P extends FieldValues> =
|
|
28
|
+
UseControllerProps<P> &
|
|
29
|
+
Omit<Omit<MuiRadioProps, "checked">, keyof ControllerRenderProps<P>> & {
|
|
30
|
+
label?: string;
|
|
31
|
+
options: Options[];
|
|
32
|
+
loading?: boolean;
|
|
33
|
+
direction?: StackOwnProps["direction"];
|
|
34
|
+
sx?: SxProps;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export function RadioGroupField<P extends FieldValues>({
|
|
38
|
+
name,
|
|
39
|
+
rules,
|
|
40
|
+
label,
|
|
41
|
+
control,
|
|
42
|
+
options,
|
|
43
|
+
defaultValue,
|
|
44
|
+
size = "small",
|
|
45
|
+
color = "secondary",
|
|
46
|
+
loading = false,
|
|
47
|
+
direction = "row",
|
|
48
|
+
sx = {},
|
|
49
|
+
...restRadioButtonProps
|
|
50
|
+
}: RadioGroupFieldProps<P>) {
|
|
51
|
+
const {
|
|
52
|
+
field: { value, onChange, ...restField },
|
|
53
|
+
} = useController({ name, control, defaultValue, rules });
|
|
54
|
+
|
|
55
|
+
if (loading) {
|
|
56
|
+
return <Skeleton />;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Stack gap="5px">
|
|
61
|
+
{label && <InputLabel>{label}</InputLabel>}
|
|
62
|
+
|
|
63
|
+
<RadioGroup
|
|
64
|
+
name={name}
|
|
65
|
+
value={value}
|
|
66
|
+
onChange={(_, event) => {
|
|
67
|
+
if (event === "true") {
|
|
68
|
+
onChange(true);
|
|
69
|
+
} else if (event === "false") {
|
|
70
|
+
onChange(false);
|
|
71
|
+
} else {
|
|
72
|
+
onChange(event);
|
|
73
|
+
}
|
|
74
|
+
}}
|
|
75
|
+
>
|
|
76
|
+
<Stack
|
|
77
|
+
gap={direction === "column" ? "5px" : "45px"}
|
|
78
|
+
direction={direction}
|
|
79
|
+
>
|
|
80
|
+
{options?.map(({ label, values, disabled }, index) => {
|
|
81
|
+
return (
|
|
82
|
+
// eslint-disable-next-line sonarjs/no-array-index-key
|
|
83
|
+
<Box key={index} width="max-content">
|
|
84
|
+
<FormControlLabel
|
|
85
|
+
value={values}
|
|
86
|
+
control={
|
|
87
|
+
<Radio
|
|
88
|
+
{...restField}
|
|
89
|
+
{...restRadioButtonProps}
|
|
90
|
+
color={color}
|
|
91
|
+
size={size}
|
|
92
|
+
/>
|
|
93
|
+
}
|
|
94
|
+
disabled={disabled}
|
|
95
|
+
label={label}
|
|
96
|
+
sx={sx}
|
|
97
|
+
/>
|
|
98
|
+
</Box>
|
|
99
|
+
);
|
|
100
|
+
})}
|
|
101
|
+
</Stack>
|
|
102
|
+
</RadioGroup>
|
|
103
|
+
</Stack>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Skeleton as MuiSkeleton, Stack } from "@mui/material";
|
|
2
|
+
export const Skeleton = () => {
|
|
3
|
+
return (
|
|
4
|
+
<Stack gap="10px">
|
|
5
|
+
<MuiSkeleton height="20px" width="70px" sx={{ transform: "scale(1)" }} />
|
|
6
|
+
<Stack direction="row" alignItems="center" gap="50px">
|
|
7
|
+
<Stack gap="10px" direction="row" alignItems="center">
|
|
8
|
+
<MuiSkeleton variant="circular" height="25px" width="25px" />
|
|
9
|
+
<MuiSkeleton
|
|
10
|
+
height="23px"
|
|
11
|
+
width="38px"
|
|
12
|
+
sx={{ transform: "scale(1)" }}
|
|
13
|
+
/>
|
|
14
|
+
</Stack>
|
|
15
|
+
<Stack gap="10px" direction="row" alignItems="center">
|
|
16
|
+
<MuiSkeleton variant="circular" height="25px" width="25px" />
|
|
17
|
+
<MuiSkeleton
|
|
18
|
+
height="23px"
|
|
19
|
+
width="38px"
|
|
20
|
+
sx={{ transform: "scale(1)" }}
|
|
21
|
+
/>
|
|
22
|
+
</Stack>
|
|
23
|
+
</Stack>
|
|
24
|
+
</Stack>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./RadioGroupField";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { InputAdornment } from "@mui/material";
|
|
2
|
+
import type { FieldValues } from "react-hook-form";
|
|
3
|
+
import SearchOutlinedIcon from "@mui/icons-material/SearchOutlined";
|
|
4
|
+
import type { TextFieldProps } from "../TextField";
|
|
5
|
+
import { TextField } from "../TextField";
|
|
6
|
+
|
|
7
|
+
export function SearchField<P extends FieldValues>(props: TextFieldProps<P>) {
|
|
8
|
+
return (
|
|
9
|
+
<TextField
|
|
10
|
+
placeholder="Search"
|
|
11
|
+
InputProps={{
|
|
12
|
+
startAdornment: (
|
|
13
|
+
<InputAdornment position="start">
|
|
14
|
+
<SearchOutlinedIcon fontSize="small" />
|
|
15
|
+
</InputAdornment>
|
|
16
|
+
),
|
|
17
|
+
}}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SearchField";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useController,
|
|
3
|
+
type ControllerRenderProps,
|
|
4
|
+
type FieldValues,
|
|
5
|
+
type UseControllerProps,
|
|
6
|
+
} from "react-hook-form";
|
|
7
|
+
import type { SwitchProps } from "@mui/material";
|
|
8
|
+
import { Switch as MuiSwitch } from "@mui/material";
|
|
9
|
+
import { Skeleton } from "./Skeleton";
|
|
10
|
+
|
|
11
|
+
export type SwitchFieldProps<P extends FieldValues> = UseControllerProps<P> &
|
|
12
|
+
Omit<Omit<SwitchProps, "checked">, keyof ControllerRenderProps<P>> & {
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function Switch<P extends FieldValues>({
|
|
17
|
+
name,
|
|
18
|
+
rules,
|
|
19
|
+
control,
|
|
20
|
+
defaultValue,
|
|
21
|
+
loading = false,
|
|
22
|
+
...restSwitchProps
|
|
23
|
+
}: SwitchFieldProps<P>) {
|
|
24
|
+
const {
|
|
25
|
+
field: { value = false, ...restField },
|
|
26
|
+
} = useController({ name, control, defaultValue, rules });
|
|
27
|
+
|
|
28
|
+
if (loading) {
|
|
29
|
+
return <Skeleton />;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return <MuiSwitch checked={value} {...restField} {...restSwitchProps} />;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Switch";
|