@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,504 @@
1
+ import React, { useEffect, useMemo, useRef, useState } from "react";
2
+ import {
3
+ Accordion,
4
+ AccordionDetails,
5
+ AccordionSummary,
6
+ Box,
7
+ Divider,
8
+ Drawer,
9
+ IconButton,
10
+ Stack,
11
+ Typography,
12
+ useTheme,
13
+ } from "@mui/material";
14
+ import type { FilterListType } from "./FilterTypeWrapper";
15
+ import {
16
+ FilterPopupWrapper,
17
+ GetFilterPopupComponent,
18
+ } from "./FilterPopupWrapper";
19
+ import type { FieldValues } from "react-hook-form";
20
+ import { useForm, useWatch } from "react-hook-form";
21
+ import { SvgFilterList } from "../Svgs/SvgFilterList";
22
+ import { ExpandMore } from "@mui/icons-material";
23
+ import { Switch } from "../FormFields/Switch";
24
+ import { PadBox } from "../PadBox";
25
+ import { Button } from "../Button";
26
+ import { ClearIcon } from "@mui/x-date-pickers/icons";
27
+ import { Tooltip } from "../Tooltip";
28
+ import { FilterPill } from "../Chips/FilterPill";
29
+ import { getFormValue } from "./getFormData";
30
+ import { isEmpty } from "lodash";
31
+
32
+ export type FilterListV2Props = {
33
+ filterListItems: FilterListType[];
34
+ isDisabled?: boolean;
35
+ filterListData?: FieldValues;
36
+ onApply: (data: FieldValues, isPopup?: boolean, key?: string) => void;
37
+ onChange: (data: FieldValues, isPopup: boolean) => void;
38
+ onClear: () => void;
39
+ resetFormBasedOnFields?: string;
40
+ };
41
+ export const FilterListV2 = ({
42
+ filterListItems,
43
+ isDisabled = false,
44
+ filterListData,
45
+ onApply,
46
+ onClear,
47
+ onChange,
48
+ }: FilterListV2Props) => {
49
+ const theme = useTheme();
50
+
51
+ const { iron, slate } = theme.palette.app.color;
52
+
53
+ const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
54
+
55
+ const filterPopupAnchorElm = useRef<HTMLDivElement | null>(null);
56
+
57
+ const [openFilterPopup, setOpenFilterPopup] = useState(false);
58
+
59
+ const [currentFilter, setCurrentFilter] = useState<null | FilterListType>(
60
+ null
61
+ );
62
+
63
+ const handleDateRange = (filter: FilterListType) => {
64
+ setCurrentFilter(filter);
65
+ setOpenFilterPopup(true);
66
+ };
67
+
68
+ const defaultValues: FieldValues = useMemo(() => {
69
+ return filterListItems.reduce<FieldValues>((acc, item) => {
70
+ acc[item.key] = item.value ?? null;
71
+
72
+ return acc;
73
+ }, {});
74
+ }, [filterListData]);
75
+
76
+ const {
77
+ control,
78
+ handleSubmit,
79
+ setValue,
80
+ reset,
81
+ formState: { dirtyFields },
82
+ watch,
83
+ } = useForm({
84
+ values: defaultValues,
85
+ });
86
+
87
+ const company_id = watch("company_id");
88
+
89
+ const handleClose = () => {
90
+ setAnchorEl(null);
91
+ };
92
+
93
+ const handleCloseFilterPopup = () => {
94
+ if (currentFilter?.key) {
95
+ setValue(`${currentFilter?.key}`, filterListData?.[currentFilter.key]);
96
+ }
97
+ setOpenFilterPopup(false);
98
+ };
99
+
100
+ const handlerReset = () => {
101
+ reset();
102
+ onClear();
103
+ handleClose();
104
+ };
105
+
106
+ const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
107
+ setAnchorEl(event.currentTarget);
108
+ };
109
+
110
+ const onSubmit = (data: FieldValues) => {
111
+ setOpenFilterPopup(false);
112
+ setCurrentFilter(null);
113
+
114
+ const filteredData = Object.fromEntries(
115
+ Object.entries(data).filter(
116
+ ([, value]) => value && !(Array.isArray(value) && value.length === 0)
117
+ )
118
+ );
119
+
120
+ onApply(filteredData, openFilterPopup, currentFilter?.key);
121
+ };
122
+
123
+ const handleDelete = (key: string) => {
124
+ setValue(`${key}`, null);
125
+
126
+ const newData = { ...filterListData };
127
+
128
+ delete newData[key];
129
+
130
+ onApply(newData, true, key);
131
+ };
132
+
133
+ const formData = useWatch({ control });
134
+
135
+ const currentFilterValue = currentFilter?.key
136
+ ? watch(currentFilter.key)
137
+ : null;
138
+
139
+ useEffect(() => {
140
+ onChange(formData, openFilterPopup);
141
+ }, [formData, onChange]);
142
+
143
+ useMemo(() => {
144
+ if (company_id !== filterListData?.company_id && !openFilterPopup) {
145
+ filterListItems.forEach((item) => {
146
+ setValue(`${item.key}`, null);
147
+ });
148
+ setValue("company_id", company_id);
149
+ }
150
+ }, [company_id]);
151
+
152
+ const getFilterItem = (key: string) => {
153
+ return filterListItems.find((item) => item.key === key);
154
+ };
155
+
156
+ const open = Boolean(anchorEl);
157
+
158
+ const shouldFormSubmit = useMemo(() => {
159
+ return (
160
+ isEmpty(dirtyFields) ||
161
+ Object.keys(formData).every((key) => !formData[key])
162
+ );
163
+ }, [formData, dirtyFields]);
164
+
165
+ const renderChips = (data: FieldValues) => {
166
+ return Object.entries(data).map(([key, value]) => {
167
+ if (!value) {
168
+ return;
169
+ }
170
+
171
+ const item = getFilterItem(key);
172
+
173
+ const keyValue = item && getFormValue(value, item);
174
+
175
+ if (!keyValue) {
176
+ return;
177
+ }
178
+
179
+ return (
180
+ <FilterPill
181
+ ref={filterPopupAnchorElm}
182
+ key={key}
183
+ label={
184
+ <Tooltip
185
+ // eslint-disable-next-line sonarjs/no-base-to-string
186
+ toolTipLabel={`${keyValue}`}
187
+ // eslint-disable-next-line sonarjs/no-base-to-string
188
+ >{`${item?.label}: ${keyValue}`}</Tooltip>
189
+ }
190
+ onDelete={() => handleDelete(key)}
191
+ onClick={(e: { currentTarget: HTMLDivElement | null }) => {
192
+ setOpenFilterPopup(true);
193
+ filterPopupAnchorElm.current = e.currentTarget;
194
+
195
+ const item = getFilterItem(key);
196
+
197
+ if (item) {
198
+ setCurrentFilter(item);
199
+ }
200
+ }}
201
+ />
202
+ );
203
+ });
204
+ };
205
+
206
+ return (
207
+ <Box sx={{ flexGrow: 1 }}>
208
+ <Stack
209
+ direction="row"
210
+ spacing={1}
211
+ alignItems="flex-start"
212
+ justifyContent="space-between"
213
+ >
214
+ <Stack
215
+ direction="row"
216
+ alignItems="flex-start"
217
+ sx={{
218
+ maxWidth: {
219
+ xs: "40vw",
220
+ md: "45vw",
221
+ lg: "57vw",
222
+ },
223
+ }}
224
+ >
225
+ {filterListData &&
226
+ Object.values(filterListData).some((value) => value) && (
227
+ <>
228
+ <Typography
229
+ variant="body1"
230
+ sx={{
231
+ minWidth: "60px",
232
+ marginTop: "8px",
233
+ }}
234
+ >
235
+ Filters:
236
+ </Typography>
237
+ <Stack
238
+ direction="row"
239
+ gap="5px"
240
+ marginTop="3px"
241
+ alignItems="center"
242
+ sx={{ flexWrap: "wrap", maxWidth: "100%" }}
243
+ >
244
+ {renderChips(filterListData)}
245
+ </Stack>
246
+ </>
247
+ )}
248
+ </Stack>
249
+ <Stack direction="row">
250
+ {filterListData &&
251
+ Object.values(filterListData).some((value) => value) && (
252
+ <Button onClick={() => handlerReset()} variant="text">
253
+ Clear Filter
254
+ </Button>
255
+ )}
256
+ {!isDisabled && (
257
+ <IconButton onClick={handleClick} sx={{ height: "40px" }}>
258
+ <SvgFilterList />
259
+ </IconButton>
260
+ )}
261
+ </Stack>
262
+ </Stack>
263
+ <form
264
+ onSubmit={(e) => {
265
+ e.preventDefault();
266
+
267
+ if (!shouldFormSubmit) {
268
+ handleSubmit((data) => {
269
+ onSubmit(data);
270
+ handleClose();
271
+ })();
272
+ }
273
+ }}
274
+ onKeyDown={(e) => {
275
+ if (e.key === "Enter") {
276
+ e.preventDefault();
277
+
278
+ if (!shouldFormSubmit) {
279
+ handleSubmit((data) => {
280
+ onSubmit(data);
281
+ handleClose();
282
+ })();
283
+ }
284
+ }
285
+ }}
286
+ >
287
+ <Drawer
288
+ open={open}
289
+ onClose={(_event, reason) => {
290
+ if (reason === "backdropClick") {
291
+ return;
292
+ }
293
+ handleClose();
294
+ }}
295
+ anchor="right"
296
+ sx={{
297
+ zIndex: theme.zIndex.drawer + 2,
298
+ "& .MuiPaper-root": {
299
+ width: "350px",
300
+ },
301
+ }}
302
+ >
303
+ <Stack
304
+ alignItems="flex-end"
305
+ sx={{
306
+ background: iron[600],
307
+ }}
308
+ >
309
+ <PadBox padding={{ padding: "10px 30px" }}>
310
+ <Stack
311
+ direction="row"
312
+ justifyContent="space-between"
313
+ width="100%"
314
+ alignItems="center"
315
+ >
316
+ <Typography variant="h6">Filter</Typography>
317
+ <IconButton
318
+ onClick={() => {
319
+ reset();
320
+ handleClose();
321
+ }}
322
+ >
323
+ <ClearIcon />
324
+ </IconButton>
325
+ </Stack>
326
+ </PadBox>
327
+ <Divider sx={{ width: "100%" }} />
328
+ </Stack>
329
+ <Stack flexGrow={1} sx={{ overflowX: "hidden" }}>
330
+ {filterListItems.map((filter) =>
331
+ filter.type === "switch" ? (
332
+ <Stack
333
+ key={filter.key}
334
+ direction="row"
335
+ justifyContent="space-between"
336
+ alignItems="center"
337
+ width="80%"
338
+ sx={{ padding: "10px 5px 10px 20px ", margin: "auto" }}
339
+ >
340
+ <Typography variant="body2">{filter.label}</Typography>
341
+ <Switch control={control} name={filter.key} />
342
+ </Stack>
343
+ ) : (
344
+ <Accordion
345
+ defaultExpanded={!!filterListData?.[filter.key]}
346
+ disabled={filter.isDisabled}
347
+ key={filter.key}
348
+ sx={{
349
+ "&.MuiAccordion-root.Mui-expanded": {
350
+ margin: "0 !important",
351
+ },
352
+ }}
353
+ >
354
+ <AccordionSummary
355
+ expandIcon={<ExpandMore />}
356
+ aria-controls="panel1a-content"
357
+ id="panel1a-header"
358
+ sx={{
359
+ flexDirection: "row-reverse",
360
+ "& MuiAccordionSummary-root.Mui-expanded": {
361
+ marginRight: "10px",
362
+ transform: "rotate(-90deg)",
363
+ },
364
+ "&.Mui-expanded": {
365
+ minHeight: "40px",
366
+ paddingY: "5px",
367
+ },
368
+ "& .MuiAccordionSummary-content.Mui-expanded": {
369
+ margin: "0px",
370
+ },
371
+ }}
372
+ >
373
+ <Stack
374
+ direction="row"
375
+ justifyContent="space-between"
376
+ alignItems="center"
377
+ width="90%"
378
+ >
379
+ <Typography variant="body2">{filter.label}</Typography>
380
+ <Typography variant="body2">{filter.menuInfo}</Typography>
381
+ </Stack>
382
+ </AccordionSummary>
383
+ <AccordionDetails
384
+ sx={{
385
+ background: slate[600],
386
+ borderRadius: "5px",
387
+ padding: "0px",
388
+ }}
389
+ >
390
+ <PadBox
391
+ padding={{
392
+ paddingLeft: "15px",
393
+ paddingY: "5px",
394
+ paddingRight: "15px",
395
+ }}
396
+ >
397
+ {filter.type === "dateRange" ? (
398
+ <Stack
399
+ direction="row"
400
+ alignItems="center"
401
+ gap="10px"
402
+ onClick={(e) => {
403
+ handleDateRange(filter);
404
+ filterPopupAnchorElm.current = e.currentTarget;
405
+ }}
406
+ >
407
+ <Box
408
+ sx={{
409
+ border: "1px solid black",
410
+ borderRadius: "5px",
411
+ width: "150px",
412
+ p: 1,
413
+ }}
414
+ >
415
+ <Typography variant="body2">
416
+ {(Array.isArray(filterListData?.["dateRange"]) &&
417
+ filterListData?.["dateRange"][0]) ||
418
+ "Start Date"}
419
+ </Typography>
420
+ </Box>
421
+ <Typography>~</Typography>
422
+ <Box
423
+ sx={{
424
+ border: "1px solid black",
425
+ borderRadius: "5px",
426
+ width: "150px",
427
+ p: 1,
428
+ }}
429
+ >
430
+ <Typography variant="body2">
431
+ {(Array.isArray(filterListData?.["dateRange"]) &&
432
+ filterListData?.["dateRange"][1]) ||
433
+ "End Date"}
434
+ </Typography>
435
+ </Box>
436
+ </Stack>
437
+ ) : (
438
+ <Box>
439
+ {
440
+ GetFilterPopupComponent(filter, control)[
441
+ filter.type
442
+ ]
443
+ }
444
+ </Box>
445
+ )}
446
+ </PadBox>
447
+ </AccordionDetails>
448
+ </Accordion>
449
+ )
450
+ )}
451
+ </Stack>
452
+
453
+ <Divider
454
+ sx={{ width: "100%", position: "absolute", bottom: "70px" }}
455
+ />
456
+ <Stack height="70px">
457
+ <PadBox padding={{ padding: "10px" }}>
458
+ <Stack
459
+ direction="row"
460
+ gap="10px"
461
+ sx={{ position: "absolute", bottom: "15px" }}
462
+ >
463
+ <Button
464
+ type="submit"
465
+ disabled={shouldFormSubmit}
466
+ variant="contained"
467
+ onClick={() => {
468
+ handleSubmit(onSubmit)();
469
+ handleClose();
470
+ }}
471
+ >
472
+ Apply
473
+ </Button>
474
+ <Button
475
+ type="button"
476
+ onClick={() => handlerReset()}
477
+ disabled={Object.keys(formData).every(
478
+ (key) => !formData[key]
479
+ )}
480
+ variant="outlined"
481
+ >
482
+ Reset
483
+ </Button>
484
+ </Stack>
485
+ </PadBox>
486
+ </Stack>
487
+ </Drawer>
488
+ </form>
489
+ {currentFilter && currentFilter.type !== "switch" && (
490
+ <FilterPopupWrapper
491
+ open={openFilterPopup}
492
+ onClose={handleCloseFilterPopup}
493
+ onApply={() => {
494
+ handleSubmit(onSubmit)();
495
+ }}
496
+ control={control}
497
+ anchorEl={filterPopupAnchorElm.current}
498
+ filterItem={currentFilter}
499
+ currentFilterValue={currentFilterValue}
500
+ />
501
+ )}
502
+ </Box>
503
+ );
504
+ };
@@ -0,0 +1,148 @@
1
+ import { useEffect, useState, type PropsWithChildren } from "react";
2
+ import type { PopoverProps } from "@mui/material";
3
+ import ClearIcon from "@mui/icons-material/Clear";
4
+ import {
5
+ Box,
6
+ Divider,
7
+ IconButton,
8
+ Popover,
9
+ Stack,
10
+ Typography,
11
+ useTheme,
12
+ } from "@mui/material";
13
+ import { Button } from "../Button";
14
+ import { PadBox } from "../PadBox";
15
+ import { isFunction, sortBy } from "lodash";
16
+ import type { FilterListType } from "./FilterTypeWrapper";
17
+
18
+ type FilterPopupProps = PropsWithChildren<PopoverProps> & {
19
+ onApply?: () => void;
20
+ showFooter?: boolean;
21
+ showDivider?: boolean;
22
+ title?: string;
23
+ background?: boolean;
24
+ filterItem?: FilterListType;
25
+ currentFilterValue?: string | string[] | null;
26
+ };
27
+
28
+ export const FilterPopup = ({
29
+ open,
30
+ anchorEl,
31
+ onClose,
32
+ children,
33
+ onApply,
34
+ showDivider = false,
35
+ showFooter = true,
36
+ title,
37
+ filterItem,
38
+ background = false,
39
+ currentFilterValue,
40
+ }: FilterPopupProps) => {
41
+ const theme = useTheme();
42
+
43
+ const { slate } = theme.palette.app.color;
44
+
45
+ const [initialValue, setInitialValue] = useState<string | string[] | null>(
46
+ null
47
+ );
48
+
49
+ const [isDisabled, setIsDisabled] = useState(true);
50
+
51
+ useEffect(() => {
52
+ if (open) {
53
+ if (!initialValue && !!currentFilterValue) {
54
+ const changedValue = filterItem?.multiSelect
55
+ ? sortBy(currentFilterValue)
56
+ : currentFilterValue;
57
+
58
+ setInitialValue(changedValue);
59
+ }
60
+ } else {
61
+ setInitialValue(null);
62
+ }
63
+
64
+ if (!!currentFilterValue && !!initialValue) {
65
+ const isChanged = filterItem?.multiSelect
66
+ ? JSON.stringify(sortBy(currentFilterValue)) !==
67
+ JSON.stringify(initialValue)
68
+ : currentFilterValue !== initialValue;
69
+
70
+ setIsDisabled(!isChanged);
71
+ }
72
+ }, [open, currentFilterValue, initialValue, filterItem?.multiSelect]);
73
+
74
+ const handleApply = () => {
75
+ setInitialValue(null);
76
+
77
+ if (isFunction(onApply)) {
78
+ onApply();
79
+ }
80
+ };
81
+
82
+ const handleClose = () => {
83
+ setInitialValue(null);
84
+
85
+ if (isFunction(onClose)) {
86
+ onClose({}, "backdropClick");
87
+ }
88
+ };
89
+
90
+ return (
91
+ <Popover
92
+ open={open}
93
+ anchorEl={anchorEl}
94
+ anchorOrigin={{ vertical: "bottom", horizontal: "left" }}
95
+ onClose={(_event, reason) => {
96
+ if (reason === "backdropClick") {
97
+ return;
98
+ }
99
+ handleClose();
100
+ }}
101
+ sx={{ "& .MuiPaper-root": { minWidth: "300px" } }}
102
+ >
103
+ {showDivider && (
104
+ <Stack alignItems="flex-end">
105
+ <PadBox padding={{ padding: "8px" }}>
106
+ <Stack
107
+ direction="row"
108
+ justifyContent="space-between"
109
+ width="100%"
110
+ alignItems="center"
111
+ >
112
+ <Typography variant="h6">{title}</Typography>
113
+ <IconButton onClick={handleClose}>
114
+ <ClearIcon />
115
+ </IconButton>
116
+ </Stack>
117
+ </PadBox>
118
+ <Divider sx={{ width: "100%" }} />
119
+ </Stack>
120
+ )}
121
+
122
+ <Box
123
+ sx={{
124
+ background: background ? slate[600] : "transparent",
125
+ borderRadius: "5px",
126
+ maxWidth: "300px",
127
+ }}
128
+ >
129
+ {children}
130
+ </Box>
131
+
132
+ {showFooter && (
133
+ <PadBox padding={{ padding: "10px" }}>
134
+ <Stack direction="row" justifyContent="flex-end">
135
+ <Button
136
+ onClick={handleApply}
137
+ disabled={isDisabled}
138
+ variant="text"
139
+ sx={{ maxWidth: "40px" }}
140
+ >
141
+ Apply
142
+ </Button>
143
+ </Stack>
144
+ </PadBox>
145
+ )}
146
+ </Popover>
147
+ );
148
+ };