@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.
Files changed (267) hide show
  1. package/.github/workflows/deploy-storybook.yml +40 -0
  2. package/.husky/commit-msg +4 -0
  3. package/.husky/pre-commit +4 -0
  4. package/.husky/pre-push +4 -0
  5. package/.lintstagedrc +5 -0
  6. package/.prettierignore +11 -0
  7. package/.prettierrc +22 -0
  8. package/.vscode/extensions.json +22 -0
  9. package/.vscode/settings.json +17 -0
  10. package/README.md +81 -0
  11. package/apps/docs/.eslintrc.cjs +4 -0
  12. package/apps/docs/.eslintrc.js +9 -0
  13. package/apps/docs/.storybook/main.ts +23 -0
  14. package/apps/docs/.storybook/preview.tsx +27 -0
  15. package/apps/docs/next-env.d.ts +5 -0
  16. package/apps/docs/next.config.mjs +4 -0
  17. package/apps/docs/package.json +38 -0
  18. package/apps/docs/public/globals.css +25 -0
  19. package/apps/docs/stories/AgGrid/AgGrid.stories.tsx +69 -0
  20. package/apps/docs/stories/AppBar/AppBar.stories.tsx +39 -0
  21. package/apps/docs/stories/Breadcrumbs/Breadcrumbs.stories.tsx +37 -0
  22. package/apps/docs/stories/Button/ButtonGroup.stories.tsx +99 -0
  23. package/apps/docs/stories/Button/button.stories.tsx +99 -0
  24. package/apps/docs/stories/Card/AttendanceCard.stories.tsx +37 -0
  25. package/apps/docs/stories/Card/Card.stories.tsx +39 -0
  26. package/apps/docs/stories/Charts/PieChart.stories.tsx +264 -0
  27. package/apps/docs/stories/Chips/Chip.stories.tsx +141 -0
  28. package/apps/docs/stories/Chips/ChipWithBorder.stories.tsx +18 -0
  29. package/apps/docs/stories/Chips/FilterPill.stories.tsx +24 -0
  30. package/apps/docs/stories/Color/Color.stories.tsx +14 -0
  31. package/apps/docs/stories/Dialog/ButtomDialog.stories.tsx +47 -0
  32. package/apps/docs/stories/Dialog/DeleteDialog.stories.tsx +31 -0
  33. package/apps/docs/stories/Dialog/Dialog.stories.tsx +47 -0
  34. package/apps/docs/stories/Drawer/Drawer.stories.tsx +94 -0
  35. package/apps/docs/stories/FilterList/FilterList.stories.tsx +88 -0
  36. package/apps/docs/stories/FilterList/FilterListV2.stories.tsx +92 -0
  37. package/apps/docs/stories/FormFields/AutoComplete.stories.tsx +87 -0
  38. package/apps/docs/stories/FormFields/CheckBox.stories.tsx +61 -0
  39. package/apps/docs/stories/FormFields/DatePicker.stories.tsx +98 -0
  40. package/apps/docs/stories/FormFields/DateRangePicker.stories.tsx +37 -0
  41. package/apps/docs/stories/FormFields/FileUpload.stories.tsx +83 -0
  42. package/apps/docs/stories/FormFields/ImageUpload.stories.tsx +69 -0
  43. package/apps/docs/stories/FormFields/ListItemButton.stories.tsx +59 -0
  44. package/apps/docs/stories/FormFields/RadioGroupField.stories.tsx +170 -0
  45. package/apps/docs/stories/FormFields/SearchField.stories.tsx +72 -0
  46. package/apps/docs/stories/FormFields/TextField.stories.tsx +111 -0
  47. package/apps/docs/stories/FormFields/TimeField.stories.tsx +82 -0
  48. package/apps/docs/stories/FormFields/TimePicker.stories.tsx +82 -0
  49. package/apps/docs/stories/Indicator/Indicator.stories.tsx +33 -0
  50. package/apps/docs/stories/Indicator/SeverityIndicator.stories.tsx +27 -0
  51. package/apps/docs/stories/Layouts/FormRow.stories.tsx +45 -0
  52. package/apps/docs/stories/PadBox/PadBox.stories.tsx +49 -0
  53. package/apps/docs/stories/Stepper/Stepper.stories.tsx +75 -0
  54. package/apps/docs/stories/Stepper/StepperV2.stories.tsx +44 -0
  55. package/apps/docs/stories/Timeline/AttendanceStatus.stories.tsx +29 -0
  56. package/apps/docs/stories/Timeline/Timeline.stories.tsx +38 -0
  57. package/apps/docs/stories/Tooltip/Tooltip.stories.tsx +30 -0
  58. package/apps/docs/stories/UserProfileMenu/UserProfileMenu.stories.tsx +112 -0
  59. package/apps/docs/tsconfig.json +19 -0
  60. package/commitlint.config.cjs +6 -0
  61. package/index.ts +1 -0
  62. package/package.json +74 -0
  63. package/packages/eslint-config/README.md +3 -0
  64. package/packages/eslint-config/library.js +88 -0
  65. package/packages/eslint-config/next.js +85 -0
  66. package/packages/eslint-config/package.json +19 -0
  67. package/packages/eslint-config/react-internal.js +89 -0
  68. package/packages/shared-components/.eslintrc.js +10 -0
  69. package/packages/shared-components/package.json +22 -0
  70. package/packages/shared-components/src/Actions/AddAction.tsx +13 -0
  71. package/packages/shared-components/src/Actions/CalendarAction.tsx +13 -0
  72. package/packages/shared-components/src/Actions/DeleteAction.tsx +13 -0
  73. package/packages/shared-components/src/Actions/DownloadAction.tsx +13 -0
  74. package/packages/shared-components/src/Actions/EditAction.tsx +13 -0
  75. package/packages/shared-components/src/Actions/HistoryAction.tsx +13 -0
  76. package/packages/shared-components/src/Actions/index.ts +6 -0
  77. package/packages/shared-components/src/AgGrid/ActionCell/ActionCell.tsx +55 -0
  78. package/packages/shared-components/src/AgGrid/ActionCell/Popover.tsx +32 -0
  79. package/packages/shared-components/src/AgGrid/AgGrid.tsx +87 -0
  80. package/packages/shared-components/src/AgGrid/LoadingCell.tsx +5 -0
  81. package/packages/shared-components/src/AgGrid/index.ts +3 -0
  82. package/packages/shared-components/src/AppBar/AppBar.styled.tsx +25 -0
  83. package/packages/shared-components/src/AppBar/AppBar.tsx +20 -0
  84. package/packages/shared-components/src/AppBar/index.ts +1 -0
  85. package/packages/shared-components/src/Breadcrumbs/Breadcrumbs.tsx +76 -0
  86. package/packages/shared-components/src/Breadcrumbs/index.ts +1 -0
  87. package/packages/shared-components/src/Button/ActionButton.tsx +38 -0
  88. package/packages/shared-components/src/Button/Button.tsx +19 -0
  89. package/packages/shared-components/src/Button/ButtonGroup.tsx +37 -0
  90. package/packages/shared-components/src/Button/index.ts +3 -0
  91. package/packages/shared-components/src/Card/AttendanceCard.tsx +51 -0
  92. package/packages/shared-components/src/Card/Card.tsx +34 -0
  93. package/packages/shared-components/src/Card/CardItem/CardItem.tsx +33 -0
  94. package/packages/shared-components/src/Card/CardItem/CardItemValue.tsx +98 -0
  95. package/packages/shared-components/src/Card/CardItem/index.ts +2 -0
  96. package/packages/shared-components/src/Card/ProfileCard/ProfileCard.tsx +40 -0
  97. package/packages/shared-components/src/Card/ProfileCard/ProfileCardItem/ProfileCardBody.tsx +53 -0
  98. package/packages/shared-components/src/Card/ProfileCard/ProfileCardItem/ProfileCardHeader.tsx +96 -0
  99. package/packages/shared-components/src/Card/index.ts +6 -0
  100. package/packages/shared-components/src/Charts/PieChart.tsx +69 -0
  101. package/packages/shared-components/src/Charts/index.ts +1 -0
  102. package/packages/shared-components/src/Chips/Chip.tsx +26 -0
  103. package/packages/shared-components/src/Chips/ChipWithBorder.tsx +39 -0
  104. package/packages/shared-components/src/Chips/FilterPill.tsx +47 -0
  105. package/packages/shared-components/src/Chips/index.ts +3 -0
  106. package/packages/shared-components/src/Dialog/BottomDialog.styled.tsx +28 -0
  107. package/packages/shared-components/src/Dialog/BottomDialog.tsx +37 -0
  108. package/packages/shared-components/src/Dialog/DeleteDialog.tsx +48 -0
  109. package/packages/shared-components/src/Dialog/Dialog.tsx +61 -0
  110. package/packages/shared-components/src/Dialog/index.ts +3 -0
  111. package/packages/shared-components/src/Drawer/Bullet.tsx +12 -0
  112. package/packages/shared-components/src/Drawer/CloseDrawer/CloseDrawerMenuItem.tsx +50 -0
  113. package/packages/shared-components/src/Drawer/CloseDrawer/CloseDrawerMenuItemList.tsx +105 -0
  114. package/packages/shared-components/src/Drawer/CloseDrawer/CloseDrawerSubMenuItemList.tsx +125 -0
  115. package/packages/shared-components/src/Drawer/CloseDrawer/MenuItem.tsx +0 -0
  116. package/packages/shared-components/src/Drawer/CloseDrawer/Popover.tsx +45 -0
  117. package/packages/shared-components/src/Drawer/CloseDrawer/Popper.tsx +43 -0
  118. package/packages/shared-components/src/Drawer/Drawer.styled.tsx +51 -0
  119. package/packages/shared-components/src/Drawer/Drawer.tsx +55 -0
  120. package/packages/shared-components/src/Drawer/MenuItem.tsx +69 -0
  121. package/packages/shared-components/src/Drawer/OpenDrawer/OpenDrawerCollapse.tsx +13 -0
  122. package/packages/shared-components/src/Drawer/OpenDrawer/OpenDrawerMenuItem.tsx +46 -0
  123. package/packages/shared-components/src/Drawer/OpenDrawer/OpenDrawerMenuItemList.tsx +249 -0
  124. package/packages/shared-components/src/Drawer/index.ts +1 -0
  125. package/packages/shared-components/src/FilterList/FilterList.tsx +172 -0
  126. package/packages/shared-components/src/FilterList/FilterListV2.tsx +504 -0
  127. package/packages/shared-components/src/FilterList/FilterPopup.tsx +148 -0
  128. package/packages/shared-components/src/FilterList/FilterPopupWrapper.tsx +113 -0
  129. package/packages/shared-components/src/FilterList/FilterTypeWrapper.tsx +58 -0
  130. package/packages/shared-components/src/FilterList/getFormData.ts +29 -0
  131. package/packages/shared-components/src/FilterList/index.ts +3 -0
  132. package/packages/shared-components/src/FormFields/Autocomplete/Autocomplete.tsx +428 -0
  133. package/packages/shared-components/src/FormFields/Autocomplete/Skeleton.tsx +26 -0
  134. package/packages/shared-components/src/FormFields/Autocomplete/index.ts +1 -0
  135. package/packages/shared-components/src/FormFields/CheckBox/CheckBox.styled.tsx +67 -0
  136. package/packages/shared-components/src/FormFields/CheckBox/CheckBox.tsx +44 -0
  137. package/packages/shared-components/src/FormFields/CheckBox/Skeleton.tsx +12 -0
  138. package/packages/shared-components/src/FormFields/CheckBox/index.ts +1 -0
  139. package/packages/shared-components/src/FormFields/DatePicker/DatePicker.tsx +206 -0
  140. package/packages/shared-components/src/FormFields/DatePicker/Skeleton.tsx +21 -0
  141. package/packages/shared-components/src/FormFields/DatePicker/index.ts +1 -0
  142. package/packages/shared-components/src/FormFields/DateRangePicker/DateRangePicker.tsx +96 -0
  143. package/packages/shared-components/src/FormFields/DateRangePicker/Skeleton.tsx +38 -0
  144. package/packages/shared-components/src/FormFields/DateRangePicker/index.ts +1 -0
  145. package/packages/shared-components/src/FormFields/DateTimePicker/DateTimePicker.tsx +245 -0
  146. package/packages/shared-components/src/FormFields/DateTimePicker/Skeleton.tsx +24 -0
  147. package/packages/shared-components/src/FormFields/DateTimePicker/index.ts +1 -0
  148. package/packages/shared-components/src/FormFields/FileUpload/FileUpload.styled.tsx +22 -0
  149. package/packages/shared-components/src/FormFields/FileUpload/FileUpload.tsx +197 -0
  150. package/packages/shared-components/src/FormFields/FileUpload/Skeleton.tsx +21 -0
  151. package/packages/shared-components/src/FormFields/FileUpload/UploadedFileName.tsx +27 -0
  152. package/packages/shared-components/src/FormFields/FileUpload/index.ts +1 -0
  153. package/packages/shared-components/src/FormFields/ImageUpload/ImageUpload.styled.tsx +16 -0
  154. package/packages/shared-components/src/FormFields/ImageUpload/ImageUpload.tsx +181 -0
  155. package/packages/shared-components/src/FormFields/ImageUpload/ImageUploadView.tsx +65 -0
  156. package/packages/shared-components/src/FormFields/ImageUpload/PhotoCaptureDialog.tsx +74 -0
  157. package/packages/shared-components/src/FormFields/ImageUpload/Skeleton.tsx +31 -0
  158. package/packages/shared-components/src/FormFields/ImageUpload/index.ts +2 -0
  159. package/packages/shared-components/src/FormFields/ListItemButton/ListItemButton.styled.tsx +22 -0
  160. package/packages/shared-components/src/FormFields/ListItemButton/ListItemButton.tsx +37 -0
  161. package/packages/shared-components/src/FormFields/ListItemButton/index.ts +1 -0
  162. package/packages/shared-components/src/FormFields/PasswordField/PasswordField.tsx +50 -0
  163. package/packages/shared-components/src/FormFields/PasswordField/index.ts +1 -0
  164. package/packages/shared-components/src/FormFields/RadioGroupField/RadioGroupField.tsx +105 -0
  165. package/packages/shared-components/src/FormFields/RadioGroupField/Skeleton.tsx +26 -0
  166. package/packages/shared-components/src/FormFields/RadioGroupField/index.ts +1 -0
  167. package/packages/shared-components/src/FormFields/SearchField/SearchField.tsx +21 -0
  168. package/packages/shared-components/src/FormFields/SearchField/index.ts +1 -0
  169. package/packages/shared-components/src/FormFields/Switch/Skeleton.tsx +12 -0
  170. package/packages/shared-components/src/FormFields/Switch/Switch.tsx +33 -0
  171. package/packages/shared-components/src/FormFields/Switch/index.ts +1 -0
  172. package/packages/shared-components/src/FormFields/TextField/Skeleton.tsx +26 -0
  173. package/packages/shared-components/src/FormFields/TextField/TextField.tsx +92 -0
  174. package/packages/shared-components/src/FormFields/TextField/index.ts +1 -0
  175. package/packages/shared-components/src/FormFields/TimeField/Skeleton.tsx +24 -0
  176. package/packages/shared-components/src/FormFields/TimeField/TimeField.tsx +120 -0
  177. package/packages/shared-components/src/FormFields/TimeField/index.ts +1 -0
  178. package/packages/shared-components/src/FormFields/TimePicker/Skeleton.tsx +24 -0
  179. package/packages/shared-components/src/FormFields/TimePicker/TimePicker.tsx +162 -0
  180. package/packages/shared-components/src/FormFields/TimePicker/index.ts +1 -0
  181. package/packages/shared-components/src/FormFields/index.ts +13 -0
  182. package/packages/shared-components/src/Indicator/Indicator.tsx +17 -0
  183. package/packages/shared-components/src/Indicator/SeverityIndicator.tsx +34 -0
  184. package/packages/shared-components/src/Indicator/index.ts +2 -0
  185. package/packages/shared-components/src/Layouts/FormContainer.tsx +6 -0
  186. package/packages/shared-components/src/Layouts/FormRow/FormRow.styled.tsx +39 -0
  187. package/packages/shared-components/src/Layouts/FormRow/FormRow.tsx +20 -0
  188. package/packages/shared-components/src/Layouts/FormRow/index.ts +1 -0
  189. package/packages/shared-components/src/Layouts/FormSection.tsx +22 -0
  190. package/packages/shared-components/src/Layouts/index.ts +3 -0
  191. package/packages/shared-components/src/Loader/FacebookCircularProgress.tsx +41 -0
  192. package/packages/shared-components/src/Loader/index.ts +1 -0
  193. package/packages/shared-components/src/PadBox/PadBox.tsx +21 -0
  194. package/packages/shared-components/src/PadBox/index.ts +1 -0
  195. package/packages/shared-components/src/Stepper/Stepper.tsx +54 -0
  196. package/packages/shared-components/src/Stepper/StepperV2.tsx +115 -0
  197. package/packages/shared-components/src/Stepper/StepperV3.tsx +72 -0
  198. package/packages/shared-components/src/Stepper/index.ts +3 -0
  199. package/packages/shared-components/src/Svgs/AppLogo/AppLogoMedium.tsx +65 -0
  200. package/packages/shared-components/src/Svgs/AppLogo/AppLogoSmall.tsx +48 -0
  201. package/packages/shared-components/src/Svgs/ArrowUp.tsx +11 -0
  202. package/packages/shared-components/src/Svgs/Company/CompanyBanner.tsx +480 -0
  203. package/packages/shared-components/src/Svgs/Company/index.ts +1 -0
  204. package/packages/shared-components/src/Svgs/Drawer/SettingIcon.tsx +51 -0
  205. package/packages/shared-components/src/Svgs/Drawer/SvgsEmployees.tsx +25 -0
  206. package/packages/shared-components/src/Svgs/Drawer/SvgsOrganization.tsx +36 -0
  207. package/packages/shared-components/src/Svgs/Drawer/SvgsTransaction.tsx +79 -0
  208. package/packages/shared-components/src/Svgs/Drawer/index.ts +4 -0
  209. package/packages/shared-components/src/Svgs/FormAction.tsx +118 -0
  210. package/packages/shared-components/src/Svgs/LogoIcon.tsx +74 -0
  211. package/packages/shared-components/src/Svgs/SvgAdd.tsx +28 -0
  212. package/packages/shared-components/src/Svgs/SvgCalendar.tsx +89 -0
  213. package/packages/shared-components/src/Svgs/SvgDelete.tsx +55 -0
  214. package/packages/shared-components/src/Svgs/SvgDownload.tsx +20 -0
  215. package/packages/shared-components/src/Svgs/SvgFilterList.tsx +19 -0
  216. package/packages/shared-components/src/Svgs/SvgNoLogo.tsx +66 -0
  217. package/packages/shared-components/src/Svgs/SvgNoSign.tsx +28 -0
  218. package/packages/shared-components/src/Svgs/SvgsDrop.tsx +44 -0
  219. package/packages/shared-components/src/Svgs/SvgsEdit.tsx +42 -0
  220. package/packages/shared-components/src/Svgs/SvgsHistory.tsx +40 -0
  221. package/packages/shared-components/src/Svgs/SvgsHome.tsx +16 -0
  222. package/packages/shared-components/src/Svgs/SvgsIndicator.tsx +20 -0
  223. package/packages/shared-components/src/Svgs/index.ts +12 -0
  224. package/packages/shared-components/src/Tab/Skeleton.tsx +15 -0
  225. package/packages/shared-components/src/Tab/Tabs.tsx +64 -0
  226. package/packages/shared-components/src/Tab/index.ts +1 -0
  227. package/packages/shared-components/src/Timeline/AttendanceStatus.tsx +56 -0
  228. package/packages/shared-components/src/Timeline/Timeline.tsx +171 -0
  229. package/packages/shared-components/src/Timeline/TimelineTrackSegments.tsx +121 -0
  230. package/packages/shared-components/src/Timeline/index.ts +2 -0
  231. package/packages/shared-components/src/Toast/Toast.tsx +59 -0
  232. package/packages/shared-components/src/Toast/ToastBody.tsx +26 -0
  233. package/packages/shared-components/src/Toast/ToastFooterLink.tsx +19 -0
  234. package/packages/shared-components/src/Toast/Toaster.styled.tsx +76 -0
  235. package/packages/shared-components/src/Toast/Toaster.tsx +21 -0
  236. package/packages/shared-components/src/Toast/index.ts +3 -0
  237. package/packages/shared-components/src/Toast/toasts.tsx +28 -0
  238. package/packages/shared-components/src/Toast/types.ts +13 -0
  239. package/packages/shared-components/src/Tooltip/Tooltip.tsx +36 -0
  240. package/packages/shared-components/src/Tooltip/index.ts +1 -0
  241. package/packages/shared-components/src/UserProfileMenu/UserProfileMenu.styled.tsx +37 -0
  242. package/packages/shared-components/src/UserProfileMenu/UserProfileMenu.tsx +107 -0
  243. package/packages/shared-components/src/UserProfileMenu/index.ts +1 -0
  244. package/packages/shared-components/src/index.ts +24 -0
  245. package/packages/shared-components/src/utils/colorVariant.ts +142 -0
  246. package/packages/shared-components/src/utils/date.ts +11 -0
  247. package/packages/shared-components/src/utils/file.ts +20 -0
  248. package/packages/shared-components/src/utils/fileSizeValidate.ts +5 -0
  249. package/packages/shared-components/src/utils/index.ts +5 -0
  250. package/packages/shared-components/src/utils/theme/colorPalette.ts +110 -0
  251. package/packages/shared-components/src/utils/theme/colorPaletteUI.tsx +44 -0
  252. package/packages/shared-components/src/utils/theme/paletteDark.ts +10 -0
  253. package/packages/shared-components/src/utils/theme/paletteLight.ts +31 -0
  254. package/packages/shared-components/src/utils/theme/theme.ts +289 -0
  255. package/packages/shared-components/src/utils/theme/types.ts +18 -0
  256. package/packages/shared-components/src/utils/theme/typography.ts +52 -0
  257. package/packages/shared-components/src/utils/urlToNestedObject.ts +9 -0
  258. package/packages/shared-components/tsconfig.json +8 -0
  259. package/packages/shared-components/tsconfig.lint.json +8 -0
  260. package/packages/shared-components/turbo/generators/config.ts +33 -0
  261. package/packages/shared-components/turbo/generators/templates/component.hbs +8 -0
  262. package/packages/typescript-config/base.json +20 -0
  263. package/packages/typescript-config/nextjs.json +13 -0
  264. package/packages/typescript-config/package.json +9 -0
  265. package/packages/typescript-config/react-library.json +8 -0
  266. package/pnpm-workspace.yaml +3 -0
  267. package/turbo.json +44 -0
@@ -0,0 +1,245 @@
1
+ import { Box, InputLabel, Stack, Tooltip, useTheme } from "@mui/material";
2
+ import type { DateTimePickerProps as MuiDateTimePickerProps } from "@mui/x-date-pickers/DateTimePicker";
3
+ import { DateTimePicker as MuiDateTimePicker } from "@mui/x-date-pickers/DateTimePicker";
4
+ import type { PickerValidDate } from "@mui/x-date-pickers/models";
5
+ import { DateTime } from "luxon";
6
+ import { type ReactElement, useState } from "react";
7
+ import type {
8
+ FieldError,
9
+ FieldValues,
10
+ Path,
11
+ PathValue,
12
+ UseControllerProps,
13
+ } from "react-hook-form";
14
+ import { useController } from "react-hook-form";
15
+ import { Skeleton } from "./Skeleton";
16
+ import { CalendarAction } from "../../Actions";
17
+ import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
18
+ import ChevronRightIcon from "@mui/icons-material/ChevronRight";
19
+
20
+ export type DateTimePickerProps<P extends FieldValues> = UseControllerProps<P> &
21
+ MuiDateTimePickerProps<PickerValidDate> &
22
+ Partial<{
23
+ label: string;
24
+ required: boolean;
25
+ disabled: boolean;
26
+ format: string;
27
+ error: boolean;
28
+ helperText: string;
29
+ loading: boolean;
30
+ clearable?: boolean;
31
+ helperIcon?: ReactElement;
32
+ toolTipText?: string;
33
+
34
+ setError: (
35
+ name: keyof P,
36
+ error: FieldError | { type: string; message?: string }
37
+ ) => void;
38
+ }>;
39
+
40
+ export const LeftArrowIcon: React.FC = () => {
41
+ const theme = useTheme();
42
+
43
+ const { iron } = theme.palette.app.color;
44
+
45
+ return (
46
+ <ChevronLeftIcon
47
+ sx={{
48
+ border: `1px solid ${iron[800]}`,
49
+ borderRadius: "5px",
50
+ p: "4px",
51
+ }}
52
+ />
53
+ );
54
+ };
55
+
56
+ export const RightArrowIcon: React.FC = () => {
57
+ const theme = useTheme();
58
+
59
+ const { iron } = theme.palette.app.color;
60
+
61
+ return (
62
+ <ChevronRightIcon
63
+ sx={{
64
+ border: `1px solid ${iron[800]}`,
65
+ borderRadius: "5px",
66
+ p: "4px",
67
+ }}
68
+ />
69
+ );
70
+ };
71
+
72
+ export function DateTimePicker<P extends FieldValues>({
73
+ control,
74
+ defaultValue,
75
+ disabled = false,
76
+ label,
77
+ readOnly = false,
78
+ name,
79
+ error = false,
80
+ helperText,
81
+ loading = false,
82
+ required = false,
83
+ clearable = true,
84
+ rules,
85
+ format = "dd-MM-yyyy HH:mm",
86
+ helperIcon,
87
+ toolTipText,
88
+ ...restProps
89
+ }: DateTimePickerProps<P>) {
90
+ const {
91
+ field: { value, onChange, ...restField },
92
+ } = useController({ name, control, defaultValue, rules });
93
+
94
+ const [open, setOpen] = useState(false);
95
+
96
+ if (error && value && typeof value === "object") {
97
+ helperText = "Invalid time";
98
+ }
99
+
100
+ const theme = useTheme();
101
+
102
+ const { iron, butterflyBlue, mirage } = theme.palette.app.color;
103
+
104
+ const pickerValue = value
105
+ ? // eslint-disable-next-line sonarjs/no-nested-conditional
106
+ (DateTime.fromISO(value) as PathValue<P, Path<P> & (string | undefined)>)
107
+ : null;
108
+
109
+ if (loading) {
110
+ return (
111
+ <Box sx={{ width: "350px" }}>
112
+ <Skeleton label={label} />
113
+ </Box>
114
+ );
115
+ }
116
+
117
+ const EmptyIcon = () => null;
118
+
119
+ return (
120
+ <Stack gap="10px">
121
+ {label && (
122
+ <Stack alignItems="center" flexDirection="row" gap="5px">
123
+ <InputLabel required={required} disabled={disabled}>
124
+ {label}
125
+ </InputLabel>
126
+ {helperIcon && toolTipText && (
127
+ <Tooltip title={toolTipText} placement="bottom">
128
+ {helperIcon}
129
+ </Tooltip>
130
+ )}
131
+ </Stack>
132
+ )}
133
+ <MuiDateTimePicker<DateTime>
134
+ {...restField}
135
+ {...restProps}
136
+ disabled={disabled}
137
+ readOnly={readOnly}
138
+ open={open}
139
+ ampm={false}
140
+ value={pickerValue}
141
+ format={format}
142
+ onOpen={() => setOpen(true)}
143
+ onClose={() => setOpen(false)}
144
+ slotProps={{
145
+ field: {
146
+ clearable,
147
+ onClear: () => onChange(null),
148
+ },
149
+ textField: {
150
+ disabled,
151
+ helperText,
152
+ error,
153
+ InputProps: {
154
+ endAdornment: <CalendarAction onClick={() => setOpen(true)} />,
155
+ sx: {
156
+ "& .MuiInputAdornment-root": {
157
+ width: "30px",
158
+ },
159
+ },
160
+ },
161
+ },
162
+ popper: {
163
+ sx: {
164
+ "& .MuiList-padding": {
165
+ padding: "10px",
166
+ },
167
+ "& .MuiMultiSectionDigitalClockSection-item": {
168
+ padding: "4px",
169
+ },
170
+ "& .MuiMultiSectionDigitalClockSection-item.Mui-selected": {
171
+ backgroundColor: butterflyBlue[900],
172
+ borderRadius: "5px",
173
+ },
174
+ "& .MuiMultiSectionDigitalClockSection-item.Mui-selected:hover": {
175
+ backgroundColor: butterflyBlue[900],
176
+ borderRadius: "5px",
177
+ },
178
+ "& .Mui-selected:hover": {
179
+ backgroundColor: butterflyBlue[900],
180
+ borderRadius: "5px",
181
+ },
182
+ "& .MuiMultiSectionDigitalClockSection-item.Mui-selected:focus-visible":
183
+ {
184
+ backgroundColor: butterflyBlue[900],
185
+ borderRadius: "5px",
186
+ },
187
+ "& .Mui-selected:focus-visible": {
188
+ backgroundColor: butterflyBlue[900],
189
+ borderRadius: "5px",
190
+ },
191
+ },
192
+ },
193
+ day: {
194
+ sx: {
195
+ "&.MuiPickersDay-root": {
196
+ borderRadius: "5px",
197
+ borderColor: butterflyBlue[900],
198
+ fontWeight: 500,
199
+ color: mirage[900],
200
+ },
201
+ "&.MuiPickersDay-root.Mui-selected": {
202
+ backgroundColor: butterflyBlue[900],
203
+ color: iron[600],
204
+ },
205
+ "&.MuiPickersDay-today": {
206
+ color: butterflyBlue[900],
207
+ backgroundColor: iron[600],
208
+ },
209
+ ":focus": {
210
+ backgroundColor: "transparent",
211
+ },
212
+ },
213
+ },
214
+ calendarHeader: {
215
+ sx: {
216
+ "& .MuiPickersCalendarHeader-label": {
217
+ fontWeight: "bold",
218
+ },
219
+ },
220
+ },
221
+ yearButton: {
222
+ sx: {
223
+ "&.MuiPickersYear-yearButton.Mui-selected": {
224
+ backgroundColor: butterflyBlue[900],
225
+ },
226
+ },
227
+ },
228
+ }}
229
+ slots={{
230
+ leftArrowIcon: LeftArrowIcon,
231
+ rightArrowIcon: RightArrowIcon,
232
+ switchViewIcon: EmptyIcon,
233
+ }}
234
+ shouldDisableTime={() => !pickerValue}
235
+ onChange={(value) => {
236
+ if (value?.isValid) {
237
+ return onChange(value.toUTC().toISO());
238
+ }
239
+
240
+ onChange(value);
241
+ }}
242
+ />
243
+ </Stack>
244
+ );
245
+ }
@@ -0,0 +1,24 @@
1
+ import { Skeleton as MuiSkeleton, Stack } from "@mui/material";
2
+
3
+ export const Skeleton = ({ label }: { label?: string }) => {
4
+ return (
5
+ <Stack gap="10px" flex={1}>
6
+ {label && (
7
+ <MuiSkeleton
8
+ width={120}
9
+ height="23px"
10
+ sx={{
11
+ transform: "scale(1)",
12
+ }}
13
+ />
14
+ )}
15
+ <MuiSkeleton
16
+ height="40px"
17
+ width="100%"
18
+ sx={{
19
+ transform: "scale(1)",
20
+ }}
21
+ />
22
+ </Stack>
23
+ );
24
+ };
@@ -0,0 +1 @@
1
+ export * from "./DateTimePicker";
@@ -0,0 +1,22 @@
1
+ import { Box, styled } from "@mui/material";
2
+
3
+ export type FileUploadContainerProps = {
4
+ error?: boolean;
5
+ };
6
+
7
+ export const FileUploadContainer = styled(Box)<FileUploadContainerProps>(
8
+ ({ theme, error }) => ({
9
+ border: error
10
+ ? `2px dashed ${theme.palette.app.color.red[900]}`
11
+ : `2px dashed ${theme.palette.app.color.iron[800]}`,
12
+ borderRadius: "8px",
13
+ cursor: "pointer",
14
+ "&:hover": {
15
+ borderColor: theme.palette.app.color.butterflyBlue[900],
16
+ },
17
+ })
18
+ );
19
+
20
+ export const FileInput = styled("input")({
21
+ display: "none",
22
+ });
@@ -0,0 +1,197 @@
1
+ import { InputLabel, Stack, Typography, useTheme } from "@mui/material";
2
+ import { drop, isFunction, join, last, remove, split } from "lodash";
3
+ import { useRef } from "react";
4
+ import type {
5
+ FieldValues,
6
+ UseControllerProps,
7
+ UseFormSetError,
8
+ } from "react-hook-form";
9
+ import { useTranslation } from "react-i18next";
10
+ import { v4 as uuidv4 } from "uuid";
11
+ import { PadBox } from "../../PadBox";
12
+ import { SvgsDrop } from "../../Svgs";
13
+ import { isFileSizeValid, isFileTypeValid } from "../../utils";
14
+ import { FileInput, FileUploadContainer } from "./FileUpload.styled";
15
+ import { Skeleton } from "./Skeleton";
16
+ import { UploadedFileName } from "./UploadedFileName";
17
+
18
+ export type FileUploadProps<P extends FieldValues> = UseControllerProps<P> & {
19
+ multiple?: boolean;
20
+ loading?: boolean;
21
+ isDisabled?: boolean;
22
+ onChange: (file: File[]) => void;
23
+ onDelete: (file: string[]) => void;
24
+ uploadedFiles: string[];
25
+ error?: boolean;
26
+ helperText?: string;
27
+ label?: string;
28
+ size?: number; //Note:- Size in MB
29
+ accept?: string;
30
+ setError?: UseFormSetError<FieldValues>;
31
+ };
32
+
33
+ export function FileUpload<P extends FieldValues>({
34
+ loading = false,
35
+ uploadedFiles,
36
+ onChange,
37
+ onDelete,
38
+ isDisabled,
39
+ multiple = false,
40
+ error,
41
+ helperText,
42
+ label,
43
+ size = 10,
44
+ setError,
45
+ accept = ".png,.jpg,.jpeg,.doc,.docx,.pdf",
46
+ ...restProps
47
+ }: FileUploadProps<P>) {
48
+ const theme = useTheme();
49
+
50
+ const { red } = theme.palette.app.color;
51
+
52
+ const { t } = useTranslation();
53
+
54
+ const inputRef = useRef<HTMLInputElement | null>(null);
55
+
56
+ const getFileName = (url: string) => {
57
+ const imageName = join(drop(split(last(split(url, "/")), "_")), "_");
58
+
59
+ return imageName;
60
+ };
61
+
62
+ const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
63
+ if (event.target.files) {
64
+ const files = Array.from(event.target.files);
65
+
66
+ const uploadFiles: File[] = [];
67
+
68
+ const inValidFiles: string[] = [];
69
+
70
+ let isShowError: boolean = false;
71
+
72
+ for (const element of files) {
73
+ if (!isFileSizeValid(element, size)) {
74
+ isShowError = true;
75
+
76
+ inValidFiles.push(
77
+ t("fileUpload.fileSize.error.message", {
78
+ fileName: element.name,
79
+ fileSize: size,
80
+ })
81
+ );
82
+ } else if (!isFileTypeValid(element)) {
83
+ isShowError = true;
84
+
85
+ inValidFiles.push(
86
+ t("fileUpload.fileType.error.message", {
87
+ fileName: element.name,
88
+ })
89
+ );
90
+ } else {
91
+ uploadFiles.push(element);
92
+ }
93
+ }
94
+
95
+ if (isShowError) {
96
+ if (isFunction(setError)) {
97
+ setError("document_url", {
98
+ type: "custom",
99
+ message: inValidFiles.join("\n"),
100
+ });
101
+ }
102
+
103
+ return;
104
+ }
105
+
106
+ if (uploadFiles?.length > 0) {
107
+ onChange(uploadFiles);
108
+ }
109
+ }
110
+ };
111
+
112
+ const handleFileRemove = (index: number) => {
113
+ if (multiple && Array.isArray(uploadedFiles)) {
114
+ const copyOfUploadedFiles = [...uploadedFiles];
115
+
116
+ remove(copyOfUploadedFiles, (_, i) => i === index);
117
+
118
+ onDelete(copyOfUploadedFiles.length > 0 ? copyOfUploadedFiles : []);
119
+ } else {
120
+ onDelete([]);
121
+ }
122
+
123
+ if (inputRef.current) {
124
+ inputRef.current.value = "";
125
+ }
126
+ };
127
+
128
+ const renderFileNames = () => {
129
+ if (!uploadedFiles) {
130
+ return null;
131
+ }
132
+
133
+ if (Array.isArray(uploadedFiles)) {
134
+ return uploadedFiles.map((file: string, index: number) => {
135
+ return (
136
+ <UploadedFileName
137
+ key={uuidv4()}
138
+ fileName={getFileName(file)}
139
+ onDelete={() => handleFileRemove(index)}
140
+ />
141
+ );
142
+ });
143
+ }
144
+ };
145
+
146
+ if (loading) {
147
+ return <Skeleton />;
148
+ }
149
+
150
+ return (
151
+ <Stack gap="10px">
152
+ <InputLabel required>{label}</InputLabel>
153
+
154
+ <FileUploadContainer
155
+ onClick={() => inputRef.current?.click()}
156
+ error={error}
157
+ {...restProps}
158
+ >
159
+ <PadBox padding={{ padding: "20px" }}>
160
+ <Stack gap="4px" alignItems="center" justifyContent="center">
161
+ <FileInput
162
+ disabled={isDisabled}
163
+ type="file"
164
+ accept={accept}
165
+ ref={inputRef}
166
+ onChange={handleFileChange}
167
+ multiple={multiple}
168
+ />
169
+
170
+ <SvgsDrop />
171
+
172
+ <Typography>Drag & drop files or Browse</Typography>
173
+
174
+ <Typography variant="caption">
175
+ Only JPG, PNG, PDF files are accepted.
176
+ </Typography>
177
+ </Stack>
178
+ </PadBox>
179
+ </FileUploadContainer>
180
+
181
+ {error && (
182
+ <Typography
183
+ variant="caption"
184
+ sx={{
185
+ color: `${red[900]}`,
186
+ whiteSpace: "pre",
187
+ textWrap: "wrap",
188
+ }}
189
+ >
190
+ {helperText}
191
+ </Typography>
192
+ )}
193
+
194
+ {renderFileNames()}
195
+ </Stack>
196
+ );
197
+ }
@@ -0,0 +1,21 @@
1
+ import { Skeleton as MuiSkeleton, Stack } from "@mui/material";
2
+
3
+ export const Skeleton = () => {
4
+ return (
5
+ <Stack gap="10px">
6
+ <MuiSkeleton
7
+ width={120}
8
+ height="23px"
9
+ sx={{
10
+ transform: "scale(1)",
11
+ }}
12
+ />
13
+ <MuiSkeleton
14
+ height="141px"
15
+ sx={{
16
+ transform: "scale(1)",
17
+ }}
18
+ />
19
+ </Stack>
20
+ );
21
+ };
@@ -0,0 +1,27 @@
1
+ import { AttachFile } from "@mui/icons-material";
2
+ import DeleteOutlineOutlinedIcon from "@mui/icons-material/DeleteOutlineOutlined";
3
+ import { IconButton, Stack, Typography } from "@mui/material";
4
+
5
+ type UploadedFileNameProps = {
6
+ fileName: string;
7
+ onDelete: () => void;
8
+ };
9
+
10
+ export const UploadedFileName = ({
11
+ fileName,
12
+ onDelete,
13
+ }: UploadedFileNameProps) => {
14
+ return (
15
+ <Stack direction="row" justifyContent="space-between" alignItems="center">
16
+ <Stack direction="row" gap="8x">
17
+ <AttachFile />
18
+
19
+ <Typography>{fileName}</Typography>
20
+ </Stack>
21
+
22
+ <IconButton onClick={onDelete}>
23
+ <DeleteOutlineOutlinedIcon />
24
+ </IconButton>
25
+ </Stack>
26
+ );
27
+ };
@@ -0,0 +1 @@
1
+ export * from "./FileUpload";
@@ -0,0 +1,16 @@
1
+ import { Box, styled } from "@mui/material";
2
+
3
+ export const DarkBackgroundContainer = styled(Box)(({ theme }) => {
4
+ return {
5
+ position: "absolute",
6
+ top: 0,
7
+ left: 0,
8
+ right: 0,
9
+ bottom: 0,
10
+ backgroundColor: theme.palette.app.color.mirage[600],
11
+ display: "flex",
12
+ justifyContent: "center",
13
+ alignItems: "center",
14
+ transition: "opacity 0.5s ease",
15
+ };
16
+ });