@campxdev/react-blueprint 0.1.22 → 0.1.24

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 (49) hide show
  1. package/package.json +1 -1
  2. package/src/components/DataDisplay/DataTable/TablePagination.tsx +5 -3
  3. package/src/components/FeedBack/Spinner/Spinner.css +32 -0
  4. package/src/components/{Layout → FeedBack}/Spinner/Spinner.stories.tsx +1 -1
  5. package/src/components/{Layout → FeedBack}/Spinner/Spinner.tsx +1 -1
  6. package/src/components/Icons/IconComponents/ActiveDevicesIcon.tsx +56 -66
  7. package/src/components/Icons/IconComponents/CheckedCheckBoxIcon.tsx +44 -0
  8. package/src/components/Icons/IconComponents/CheckedRadioIcon.tsx +44 -0
  9. package/src/components/Icons/IconComponents/DeviceIcon.tsx +58 -0
  10. package/src/components/Icons/IconComponents/InfoIcon.tsx +42 -0
  11. package/src/components/Icons/IconComponents/InstitutionsIcon.tsx +67 -103
  12. package/src/components/Icons/IconComponents/LocationIcon.tsx +50 -0
  13. package/src/components/Icons/IconComponents/NavigationIcon.tsx +21 -25
  14. package/src/components/Icons/IconComponents/ProfileIcon.tsx +0 -4
  15. package/src/components/Icons/IconComponents/TooltipIcon.tsx +26 -0
  16. package/src/components/Icons/IconComponents/UncheckCheckBoxIcon.tsx +28 -0
  17. package/src/components/Icons/IconComponents/UncheckedRadioIcon.tsx +28 -0
  18. package/src/components/Icons/export.ts +35 -18
  19. package/src/components/Input/Button/Button.tsx +1 -1
  20. package/src/components/Input/{CheckBox/CheckBox.stories.tsx → MultiCheckBox/MultiCheckBox.stories.tsx} +1 -1
  21. package/src/components/Input/{CheckBox → MultiCheckBox}/MultiCheckBox.tsx +2 -2
  22. package/src/components/Input/RadioGroup/RadioGroup.stories.tsx +43 -0
  23. package/src/components/Input/RadioGroup/RadioGroup.tsx +56 -0
  24. package/src/components/Input/SingleCheckBox/SIngleCheckBox.tsx +33 -0
  25. package/src/components/Input/SingleCheckBox/SingleCheckBox.stories.tsx +33 -0
  26. package/src/components/Input/SingleSelect/SingleSelect.tsx +59 -24
  27. package/src/components/Input/components/FetchingOptionsLoader.tsx +5 -13
  28. package/src/components/Layout/Header/AppHeader.stories.tsx +1 -1
  29. package/src/components/Layout/Header/HeaderActions/CogWheelMenu.tsx +1 -1
  30. package/src/components/Layout/Header/HeaderActions/UserBox.tsx +2 -2
  31. package/src/components/Layout/LayoutWrapper/styles.tsx +1 -1
  32. package/src/components/Layout/SideNavigation/SideNavigation.tsx +1 -1
  33. package/src/components/{DropDownMenu → Navigation/DropDownMenu}/DropDownButton.tsx +1 -1
  34. package/src/components/{DropDownMenu → Navigation/DropDownMenu}/DropDownMenu.stories.tsx +1 -1
  35. package/src/components/{TabsContainer → Navigation/TabsContainer}/TabsContainer.stories.tsx +1 -1
  36. package/src/components/export.ts +2 -3
  37. package/src/themes/darkTheme.ts +1 -0
  38. package/src/themes/lightTheme.ts +1 -0
  39. package/src/themes/typography.stories.tsx +1 -1
  40. package/types/theme.d.ts +3 -0
  41. package/.vscode/settings.json +0 -3
  42. package/src/components/Input/CheckBox/CheckBox.tsx +0 -72
  43. package/src/components/Layout/Spinner/Spinner.css +0 -32
  44. /package/src/components/{Typography → DataDisplay/Typography}/Typography.tsx +0 -0
  45. /package/src/components/{DropDownMenu → Navigation/DropDownMenu}/DropDownIcon.tsx +0 -0
  46. /package/src/components/{DropDownMenu → Navigation/DropDownMenu}/DropDownMenu.tsx +0 -0
  47. /package/src/components/{DropDownMenu → Navigation/DropDownMenu}/DropdownMenuItem.tsx +0 -0
  48. /package/src/components/{DropDownMenu → Navigation/DropDownMenu}/styles.tsx +0 -0
  49. /package/src/components/{TabsContainer → Navigation/TabsContainer}/TabsContainer.tsx +0 -0
@@ -4,31 +4,27 @@ export const NavigationIcon = () => {
4
4
  const theme = useTheme();
5
5
  const color = theme.palette.text.primary;
6
6
  return (
7
- <>
8
- <svg
9
- xmlns="http://www.w3.org/2000/svg"
10
- width="21"
11
- height="21"
12
- viewBox="0 0 30 30"
13
- style={{
14
- stroke: color,
15
- }}
7
+ <svg
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ width="21"
10
+ height="21"
11
+ viewBox="0 0 30 30"
12
+ style={{
13
+ fill: color,
14
+ }}
15
+ >
16
+ <g
17
+ id="Mask_Group_125"
18
+ data-name="Mask Group 125"
19
+ transform="translate(-847 -594)"
20
+ clipPath="url(#clip-path)"
16
21
  >
17
- <g
18
- id="Mask_Group_125"
19
- data-name="Mask Group 125"
20
- transform="translate(-847 -594)"
21
- clipPath="url(#clip-path)"
22
- >
23
- <path
24
- id="share-square"
25
- d="M17.555,19.621a5.165,5.165,0,0,1-5.163,5.163H5.163A5.165,5.165,0,0,1,0,19.621V12.392A5.165,5.165,0,0,1,5.163,7.229H6.2a1.033,1.033,0,0,1,0,2.065H5.163a3.107,3.107,0,0,0-3.1,3.1v7.229a3.107,3.107,0,0,0,3.1,3.1h7.229a3.107,3.107,0,0,0,3.1-3.1,1.033,1.033,0,1,1,2.065,0Zm6.33-13.538L18.3.31A1.019,1.019,0,0,0,16.843.289a1.029,1.029,0,0,0-.021,1.456L22.13,7.219H13.425a5.165,5.165,0,0,0-5.163,5.163v5.163a1.033,1.033,0,0,0,2.065,0V12.382a3.107,3.107,0,0,1,3.1-3.1h8.7l-5.308,5.473a1.027,1.027,0,0,0,.744,1.745,1.066,1.066,0,0,0,.744-.31l5.576-5.752a3.1,3.1,0,0,0,.01-4.368Z"
26
- transform="translate(849.609 596.406)"
27
- fill={color}
28
- strokeWidth="0.3"
29
- />
30
- </g>
31
- </svg>
32
- </>
22
+ <path
23
+ id="share-square"
24
+ d="M17.555,19.621a5.165,5.165,0,0,1-5.163,5.163H5.163A5.165,5.165,0,0,1,0,19.621V12.392A5.165,5.165,0,0,1,5.163,7.229H6.2a1.033,1.033,0,0,1,0,2.065H5.163a3.107,3.107,0,0,0-3.1,3.1v7.229a3.107,3.107,0,0,0,3.1,3.1h7.229a3.107,3.107,0,0,0,3.1-3.1,1.033,1.033,0,1,1,2.065,0Zm6.33-13.538L18.3.31A1.019,1.019,0,0,0,16.843.289a1.029,1.029,0,0,0-.021,1.456L22.13,7.219H13.425a5.165,5.165,0,0,0-5.163,5.163v5.163a1.033,1.033,0,0,0,2.065,0V12.382a3.107,3.107,0,0,1,3.1-3.1h8.7l-5.308,5.473a1.027,1.027,0,0,0,.744,1.745,1.066,1.066,0,0,0,.744-.31l5.576-5.752a3.1,3.1,0,0,0,.01-4.368Z"
25
+ transform="translate(849.609 596.406)"
26
+ />
27
+ </g>
28
+ </svg>
33
29
  );
34
30
  };
@@ -14,7 +14,6 @@ export const ProfileIcon = () => {
14
14
  height="16"
15
15
  viewBox="0 0 16 16"
16
16
  style={{
17
- stroke: color,
18
17
  fill: color, // Set fill color to use the theme's primary text color
19
18
  }}
20
19
  >
@@ -23,21 +22,18 @@ export const ProfileIcon = () => {
23
22
  id="Vector"
24
23
  d="M6.56,14.337a2.585,2.585,0,0,1-1.3-.347L1.3,11.7A2.618,2.618,0,0,1,0,9.45V4.89A2.618,2.618,0,0,1,1.3,2.637L5.26.35a2.589,2.589,0,0,1,2.6,0l3.96,2.287a2.618,2.618,0,0,1,1.3,2.253V9.45a2.618,2.618,0,0,1-1.3,2.253L7.86,13.99A2.585,2.585,0,0,1,6.56,14.337ZM6.56,1a1.634,1.634,0,0,0-.8.213L1.8,3.5A1.6,1.6,0,0,0,1,4.89V9.45a1.612,1.612,0,0,0,.8,1.387l3.96,2.287a1.6,1.6,0,0,0,1.6,0l3.96-2.287a1.6,1.6,0,0,0,.8-1.387V4.89a1.612,1.612,0,0,0-.8-1.387L7.36,1.217A1.634,1.634,0,0,0,6.56,1Z"
25
24
  transform="translate(1.44 0.83)"
26
- strokeWidth="0.5"
27
25
  />
28
26
  <path
29
27
  id="Vector-2"
30
28
  data-name="Vector"
31
29
  d="M2.053,4.107A2.053,2.053,0,1,1,4.107,2.053,2.054,2.054,0,0,1,2.053,4.107ZM2.053,1A1.053,1.053,0,1,0,3.107,2.053,1.056,1.056,0,0,0,2.053,1Z"
32
30
  transform="translate(5.947 3.727)"
33
- strokeWidth="0.5"
34
31
  />
35
32
  <path
36
33
  id="Vector-3"
37
34
  data-name="Vector"
38
35
  d="M5.833,3.173a.5.5,0,0,1-.5-.5A1.974,1.974,0,0,0,3.167,1,1.974,1.974,0,0,0,1,2.673a.5.5,0,0,1-.5.5.5.5,0,0,1-.5-.5A2.955,2.955,0,0,1,3.167,0,2.955,2.955,0,0,1,6.333,2.673.5.5,0,0,1,5.833,3.173Z"
39
36
  transform="translate(4.833 8.433)"
40
- strokeWidth="0.5"
41
37
  />
42
38
  <path
43
39
  id="Vector-4"
@@ -0,0 +1,26 @@
1
+ import { useTheme } from "@mui/material";
2
+
3
+ export const TooltipIcon = () => {
4
+ const theme = useTheme();
5
+ const color = theme.palette.text.primary;
6
+
7
+ return (
8
+ <svg
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ width="20.182"
11
+ height="21.03"
12
+ viewBox="0 0 20.182 21.03"
13
+ style={{
14
+ fill: color,
15
+ }}
16
+ >
17
+ <g id="light-bulb" transform="translate(-9.8)" opacity="0.7">
18
+ <path
19
+ id="XMLID_49_"
20
+ d="M22.288,18.377v.614a.975.975,0,0,1-.826.965l-.151.558a.7.7,0,0,1-.671.515h-1.5a.7.7,0,0,1-.671-.515l-.147-.558a.979.979,0,0,1-.831-.969v-.614a.591.591,0,0,1,.593-.593H21.7A.6.6,0,0,1,22.288,18.377ZM25.071,10.1a5.155,5.155,0,0,1-1.454,3.6,4.751,4.751,0,0,0-1.272,2.579.857.857,0,0,1-.848.723H18.281a.848.848,0,0,1-.844-.718,4.8,4.8,0,0,0-1.281-2.588A5.18,5.18,0,1,1,25.071,10.1Zm-4.6-3.137a.584.584,0,0,0-.584-.584,3.742,3.742,0,0,0-3.739,3.739.584.584,0,1,0,1.168,0,2.573,2.573,0,0,1,2.57-2.57A.582.582,0,0,0,20.475,6.958Zm-.584-3.743a.584.584,0,0,0,.584-.584V.584a.584.584,0,1,0-1.168,0V2.631A.584.584,0,0,0,19.891,3.215Zm-6.876,6.876a.584.584,0,0,0-.584-.584H10.384a.584.584,0,1,0,0,1.168h2.047A.582.582,0,0,0,13.015,10.091ZM29.4,9.507H27.351a.584.584,0,1,0,0,1.168H29.4a.584.584,0,1,0,0-1.168ZM14.205,14.955l-1.45,1.45a.583.583,0,0,0,.822.826l1.45-1.45a.583.583,0,0,0-.822-.826ZM25.166,5.4a.583.583,0,0,0,.411-.169l1.45-1.45a.584.584,0,1,0-.826-.826l-1.45,1.45a.582.582,0,0,0,0,.826A.593.593,0,0,0,25.166,5.4ZM14.205,5.227a.583.583,0,0,0,.822-.826l-1.45-1.45a.584.584,0,0,0-.826.826Zm11.372,9.727a.584.584,0,0,0-.826.826l1.45,1.45a.583.583,0,1,0,.822-.826Z"
21
+ transform="translate(0)"
22
+ />
23
+ </g>
24
+ </svg>
25
+ );
26
+ };
@@ -0,0 +1,28 @@
1
+ import { useTheme } from "@mui/material";
2
+
3
+ export const UnCheckedCheckboxIcon = () => {
4
+ const theme = useTheme();
5
+ const color = theme.palette.secondary.main;
6
+ return (
7
+ <svg
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ width="20"
10
+ height="20"
11
+ viewBox="0 0 20 20"
12
+ style={{
13
+ fill: color,
14
+ }}
15
+ >
16
+ <g
17
+ id="Rectangle_23614"
18
+ data-name="Rectangle 23614"
19
+ fill="#f8f8f8"
20
+ stroke="rgba(18,18,18,0.1)"
21
+ stroke-width="1"
22
+ >
23
+ <rect width="20" height="20" rx="3" stroke="none" />
24
+ <rect x="0.5" y="0.5" width="19" height="19" rx="2.5" fill="none" />
25
+ </g>
26
+ </svg>
27
+ );
28
+ };
@@ -0,0 +1,28 @@
1
+ import { useTheme } from "@mui/material";
2
+
3
+ export const UnCheckedRadioIcon = () => {
4
+ const theme = useTheme();
5
+ const color = theme.palette.text.primary;
6
+ return (
7
+ <svg
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ width="20"
10
+ height="20"
11
+ viewBox="0 0 20 20"
12
+ style={{
13
+ fill: color,
14
+ }}
15
+ >
16
+ <g
17
+ id="Rectangle_23803"
18
+ data-name="Rectangle 23803"
19
+ fill="#f8f8f8"
20
+ stroke="rgba(18,18,18,0.1)"
21
+ stroke-width="1"
22
+ >
23
+ <rect width="20" height="20" rx="10" stroke="none" />
24
+ <rect x="0.5" y="0.5" width="19" height="19" rx="9.5" fill="none" />
25
+ </g>
26
+ </svg>
27
+ );
28
+ };
@@ -1,38 +1,55 @@
1
1
  import { ActiveDevicesIcon } from "./IconComponents/ActiveDevicesIcon";
2
2
  import { AppsIcon } from "./IconComponents/AppsIcon";
3
3
  import { CareerIcon } from "./IconComponents/CareerIcon";
4
+ import { CheckedCheckboxIcon } from "./IconComponents/CheckedCheckBoxIcon";
5
+ import { CheckedRadioIcon } from "./IconComponents/CheckedRadioIcon";
4
6
  import { ClogWheelIcon } from "./IconComponents/ClogWheelIcon";
5
7
  import { DashBoardIcon } from "./IconComponents/DashBoardIcon";
8
+ import { DeviceIcon } from "./IconComponents/DeviceIcon";
6
9
  import { ExamResultIcon } from "./IconComponents/ExamResultIcon";
7
10
  import { ExportIcon } from "./IconComponents/ExportIcon";
8
11
  import { FilterIcon } from "./IconComponents/FilterIcon";
9
12
  import { HelpIcon } from "./IconComponents/HelpIcon";
10
13
  import { HomeIcon } from "./IconComponents/HomeIcon";
14
+ import { InfoIcon } from "./IconComponents/InfoIcon";
15
+
11
16
  import { InstitutionsIcon } from "./IconComponents/InstitutionsIcon";
12
17
  import { LeftIcon } from "./IconComponents/LeftIcon";
18
+ import { LocationIcon } from "./IconComponents/LocationIcon";
13
19
  import { LogoutIcon } from "./IconComponents/LogoutIcon";
14
20
  import { NavigationIcon } from "./IconComponents/NavigationIcon";
15
21
  import { NotificationIcon } from "./IconComponents/NotificationIcon";
16
22
  import { ProfileIcon } from "./IconComponents/ProfileIcon";
17
23
  import { RightIcon } from "./IconComponents/RightIcon";
18
24
  import { TicketsIcon } from "./IconComponents/TicketsIcon";
25
+ import { TooltipIcon } from "./IconComponents/TooltipIcon";
26
+ import { UnCheckedCheckboxIcon } from "./IconComponents/UncheckCheckBoxIcon";
27
+ import { UnCheckedRadioIcon } from "./IconComponents/UncheckedRadioIcon";
19
28
  export const Icons = {
20
- AppsIcon: AppsIcon,
21
- CareerIcon: CareerIcon,
22
- ClogWheelIcon: ClogWheelIcon,
23
- DashBoardIcon: DashBoardIcon,
24
- HelpIcon: HelpIcon,
25
- HomeIcon: HomeIcon,
26
- LeftIcon: LeftIcon,
27
- ExamResultIcon: ExamResultIcon,
28
- NotificationIcon: NotificationIcon,
29
- RightIcon: RightIcon,
30
- LogoutIcon: LogoutIcon,
31
- TicketsIcon: TicketsIcon,
32
- FilterIcon: FilterIcon,
33
- ExportIcon: ExportIcon,
34
- ProfileIcon: ProfileIcon,
35
- InstitutionsIcon: InstitutionsIcon,
36
- ActiveDevicesIcon: ActiveDevicesIcon,
37
- NavigationIcon: NavigationIcon,
29
+ AppsIcon,
30
+ CareerIcon,
31
+ ClogWheelIcon,
32
+ DashBoardIcon,
33
+ HelpIcon,
34
+ HomeIcon,
35
+ LeftIcon,
36
+ ExamResultIcon,
37
+ NotificationIcon,
38
+ RightIcon,
39
+ LogoutIcon,
40
+ TicketsIcon,
41
+ FilterIcon,
42
+ ExportIcon,
43
+ ProfileIcon,
44
+ InstitutionsIcon,
45
+ ActiveDevicesIcon,
46
+ NavigationIcon,
47
+ UnCheckedCheckboxIcon,
48
+ CheckedCheckboxIcon,
49
+ UnCheckedRadioIcon,
50
+ CheckedRadioIcon,
51
+ TooltipIcon,
52
+ InfoIcon,
53
+ LocationIcon,
54
+ DeviceIcon,
38
55
  };
@@ -4,7 +4,7 @@ import {
4
4
  } from "@mui/material";
5
5
  import "./ButtonLoader.css";
6
6
 
7
- export type ButtonProps = { loading: boolean } & MuiButtonProps;
7
+ export type ButtonProps = { loading?: boolean } & MuiButtonProps;
8
8
 
9
9
  export const Button = ({ loading = false, ...props }: ButtonProps) => {
10
10
  return (
@@ -3,7 +3,7 @@ import { useState } from "react";
3
3
  import { MultiCheckBox, MultiCheckboxProps } from "./MultiCheckBox";
4
4
 
5
5
  export default {
6
- title: "Input/CheckBox",
6
+ title: "Input/MultiCheckBox",
7
7
  component: MultiCheckBox,
8
8
  tags: ["autodocs"],
9
9
  argTypes: {},
@@ -2,7 +2,7 @@ import { Stack, StackProps } from "@mui/material";
2
2
  import { ResponsiveStyleValue } from "@mui/system";
3
3
  import { ReactNode } from "react";
4
4
  import { LabelWrapper } from "../LabelWrapper/LabelWrapper";
5
- import { CheckBox } from "./CheckBox";
5
+ import { SingleCheckBox } from "../SingleCheckBox/SIngleCheckBox";
6
6
 
7
7
  export type MultiCheckboxProps = {
8
8
  containerProps?: StackProps;
@@ -38,7 +38,7 @@ export const MultiCheckBox = ({
38
38
  <Stack direction={direction}>
39
39
  {options?.length != 0 &&
40
40
  options?.map((item, index) => (
41
- <CheckBox
41
+ <SingleCheckBox
42
42
  key={index}
43
43
  name={name}
44
44
  checked={values?.includes(item.value)}
@@ -0,0 +1,43 @@
1
+ // Import React and other necessary elements
2
+
3
+ import { Meta } from "@storybook/react";
4
+ import { RadioGroup, RadioGroupProps } from "./RadioGroup";
5
+
6
+ // Define the default export with Meta type including the component type
7
+ export default {
8
+ title: "Input/RadioGroup",
9
+ component: RadioGroup,
10
+ tags: ["autodocs"],
11
+ argTypes: {},
12
+ } as Meta<typeof RadioGroup>;
13
+
14
+ // Define stories directly as objects with render function
15
+ export const Default = {
16
+ render: (args: RadioGroupProps) => <RadioGroup {...args} />,
17
+ args: {
18
+ label: "Radio",
19
+ options: [
20
+ {
21
+ label: "Option 1",
22
+ value: "1",
23
+ },
24
+ {
25
+ label: "Option 2",
26
+ value: "2",
27
+ },
28
+ {
29
+ label: "Option 3",
30
+ value: "3",
31
+ },
32
+ {
33
+ label: "Option 4",
34
+ value: "4",
35
+ },
36
+ ],
37
+ onChange: (event: any, value: any) => {
38
+ console.log(event.target.checked, value);
39
+ },
40
+ row: true,
41
+ defaultValue: "3",
42
+ },
43
+ };
@@ -0,0 +1,56 @@
1
+ import {
2
+ FormControlLabel,
3
+ RadioGroup as MuiRadioGroup,
4
+ RadioGroupProps as MuiRadioGroupProps,
5
+ Radio,
6
+ StackProps,
7
+ } from "@mui/material";
8
+ import { ReactNode } from "react";
9
+ import { Icons } from "../../export";
10
+ import { LabelWrapper } from "../LabelWrapper/LabelWrapper";
11
+
12
+ export type RadioGroupProps = {
13
+ containerProps?: StackProps;
14
+ options: Array<{ label: ReactNode; value: any; disabled?: boolean }>;
15
+ label: string;
16
+ required: boolean;
17
+ name: string;
18
+ disabled: boolean;
19
+ } & MuiRadioGroupProps;
20
+
21
+ export const RadioGroup = ({
22
+ label,
23
+ required,
24
+ options,
25
+ name,
26
+ containerProps,
27
+ disabled,
28
+ onChange,
29
+ ...rest
30
+ }: RadioGroupProps) => {
31
+ return (
32
+ <LabelWrapper
33
+ label={label}
34
+ required={required}
35
+ name={name}
36
+ containerProps={containerProps}
37
+ >
38
+ <MuiRadioGroup onChange={onChange} name={name} {...rest}>
39
+ {options?.map((item, index) => (
40
+ <FormControlLabel
41
+ key={index}
42
+ value={item.value}
43
+ control={
44
+ <Radio
45
+ checkedIcon={<Icons.CheckedRadioIcon />}
46
+ icon={<Icons.UnCheckedRadioIcon />}
47
+ disabled={disabled || item.disabled}
48
+ />
49
+ }
50
+ label={item.label}
51
+ />
52
+ ))}
53
+ </MuiRadioGroup>
54
+ </LabelWrapper>
55
+ );
56
+ };
@@ -0,0 +1,33 @@
1
+ import {
2
+ FormControlLabel,
3
+ Checkbox as MuiCheckbox,
4
+ CheckboxProps as MuiCheckboxProps,
5
+ } from "@mui/material";
6
+ import { ReactNode } from "react";
7
+ import { Icons } from "../../export";
8
+
9
+ export type CheckboxProps = {
10
+ label: ReactNode;
11
+ } & MuiCheckboxProps;
12
+
13
+ export const SingleCheckBox = ({
14
+ checked,
15
+ label,
16
+ onChange,
17
+ ...rest
18
+ }: CheckboxProps) => {
19
+ return (
20
+ <FormControlLabel
21
+ control={
22
+ <MuiCheckbox
23
+ checked={checked}
24
+ checkedIcon={<Icons.CheckedCheckboxIcon />}
25
+ icon={<Icons.UnCheckedCheckboxIcon />}
26
+ onChange={onChange}
27
+ {...rest}
28
+ />
29
+ }
30
+ label={label}
31
+ />
32
+ );
33
+ };
@@ -0,0 +1,33 @@
1
+ import { Meta, StoryFn } from "@storybook/react";
2
+ import { useState } from "react";
3
+
4
+ import { CheckboxProps, SingleCheckBox } from "./SIngleCheckBox";
5
+
6
+ export default {
7
+ title: "Input/SingleCheckBox",
8
+ component: SingleCheckBox,
9
+ tags: ["autodocs"],
10
+ argTypes: {},
11
+ } as Meta<typeof SingleCheckBox>;
12
+
13
+ const SingleCheckBoxStory: StoryFn<CheckboxProps> = (args) => {
14
+ const [value, setValue] = useState(args.value);
15
+ return (
16
+ <SingleCheckBox
17
+ {...args}
18
+ value={value}
19
+ onChange={(event: any) => {
20
+ console.log(value, "ll");
21
+ setValue(event.target.value);
22
+ }}
23
+ />
24
+ );
25
+ };
26
+
27
+ export const Default = SingleCheckBoxStory.bind({});
28
+ Default.args = {
29
+ label: "First Name",
30
+ required: true,
31
+ value: "ok",
32
+ onChange: (event: any) => {},
33
+ };
@@ -6,9 +6,9 @@ import {
6
6
  TextField,
7
7
  } from "@mui/material";
8
8
  import axios from "axios";
9
- import { useReducer, useRef } from "react";
9
+ import { useReducer } from "react";
10
10
  import { campxAxios } from "../../../utils/campxAxios";
11
- import { Typography } from "../../Typography/Typography";
11
+ import { Typography } from "../../DataDisplay/Typography/Typography";
12
12
  import { LabelWrapper } from "../LabelWrapper/LabelWrapper";
13
13
  import { FetchingOptionsLoader } from "../components/FetchingOptionsLoader";
14
14
  import { OptionContainer } from "../styles";
@@ -29,6 +29,13 @@ export interface SingleSelectProps {
29
29
  label?: string;
30
30
  }
31
31
 
32
+ const CustomPaper = (props: PaperProps) => (
33
+ <Paper {...props}>
34
+ {props.children}
35
+ <FetchingOptionsLoader loading={!!props.square} />
36
+ </Paper>
37
+ );
38
+
32
39
  enum SingleSelectActionsTypes {
33
40
  OPEN = "open",
34
41
  CLOSE = "close",
@@ -37,6 +44,7 @@ enum SingleSelectActionsTypes {
37
44
  SET_NETWORK_ERROR = "set_network_error",
38
45
  SET_INTERNAL_OPTIONS = "set_internal_options",
39
46
  APPEND_INTERNAL_OPTIONS = "append_internal_options",
47
+ CHANGE_HAS_MORE_FLAG = "change_has_more_flag",
40
48
  }
41
49
  const singleSelectReducer = (
42
50
  state: any,
@@ -73,6 +81,14 @@ const singleSelectReducer = (
73
81
  ...state,
74
82
  internalOptions: [...state.internalOptions, ...stateChanges.newOptions],
75
83
  loadingInternalOptions: false,
84
+ limit: state.limit,
85
+ offset: state.offset + 10,
86
+ };
87
+ }
88
+ case SingleSelectActionsTypes.CHANGE_HAS_MORE_FLAG: {
89
+ return {
90
+ ...state,
91
+ hasMore: !state.hasMore,
76
92
  };
77
93
  }
78
94
  default:
@@ -80,13 +96,6 @@ const singleSelectReducer = (
80
96
  }
81
97
  };
82
98
 
83
- const PaperComponent = (props: PaperProps, loadingInternalOptions: boolean) => (
84
- <Paper {...props}>
85
- {props.children}
86
- <FetchingOptionsLoader loading={loadingInternalOptions} />
87
- </Paper>
88
- );
89
-
90
99
  export const SingleSelect = ({
91
100
  options,
92
101
  optionsApiEndPoint,
@@ -98,9 +107,18 @@ export const SingleSelect = ({
98
107
  open: false,
99
108
  loadingInternalOptions: false,
100
109
  internalOptions: options ?? [],
110
+ limit: 10,
111
+ offset: 0,
112
+ hasMore: true,
101
113
  });
102
- const { open, loadingInternalOptions, internalOptions } = state;
103
- const listboxRef = useRef(null);
114
+ const {
115
+ open,
116
+ loadingInternalOptions,
117
+ internalOptions,
118
+ limit,
119
+ offset,
120
+ hasMore,
121
+ } = state;
104
122
 
105
123
  const internalAxios = useCampxAxios ? campxAxios : axios;
106
124
 
@@ -108,7 +126,7 @@ export const SingleSelect = ({
108
126
  dispatch({
109
127
  actionType: SingleSelectActionsTypes.OPEN,
110
128
  });
111
- if (optionsApiEndPoint) {
129
+ if (optionsApiEndPoint && !internalOptions.length) {
112
130
  try {
113
131
  dispatch({
114
132
  actionType: SingleSelectActionsTypes.LOAD_INTERNAL_OPTIONS_START,
@@ -116,11 +134,12 @@ export const SingleSelect = ({
116
134
  const options = await internalAxios
117
135
  .get(optionsApiEndPoint, {
118
136
  params: {
119
- limit: 100,
120
- offset: 0,
137
+ limit,
138
+ offset,
121
139
  },
122
140
  })
123
141
  .then((res) => res.data);
142
+ await sleep(700);
124
143
  dispatch({
125
144
  actionType: SingleSelectActionsTypes.SET_INTERNAL_OPTIONS,
126
145
  stateChanges: {
@@ -143,20 +162,32 @@ export const SingleSelect = ({
143
162
 
144
163
  const handleScroll = async (event: any) => {
145
164
  const listboxNode = event.currentTarget;
146
-
147
- console.log(
148
- listboxNode.scrollTop + listboxNode.clientHeight,
149
- listboxNode.scrollHeight
150
- );
151
165
  if (
152
166
  listboxNode.scrollTop + listboxNode.clientHeight >=
153
- listboxNode.scrollHeight - 100
167
+ listboxNode.scrollHeight - 1 &&
168
+ hasMore
154
169
  ) {
155
- console.log("dispatched");
170
+ dispatch({
171
+ actionType: SingleSelectActionsTypes.LOAD_INTERNAL_OPTIONS_START,
172
+ });
173
+ const newOptions = await internalAxios
174
+ .get(optionsApiEndPoint ?? "", {
175
+ params: {
176
+ limit: limit,
177
+ offset: offset + 10,
178
+ },
179
+ })
180
+ .then((res) => res.data);
181
+ if (newOptions.length < 10) {
182
+ dispatch({
183
+ actionType: SingleSelectActionsTypes.CHANGE_HAS_MORE_FLAG,
184
+ });
185
+ }
186
+ await sleep(700);
156
187
  dispatch({
157
188
  actionType: SingleSelectActionsTypes.APPEND_INTERNAL_OPTIONS,
158
189
  stateChanges: {
159
- newOptions: internalOptions,
190
+ newOptions: newOptions,
160
191
  },
161
192
  });
162
193
  }
@@ -171,7 +202,7 @@ export const SingleSelect = ({
171
202
  <TextField {...params} />
172
203
  </LabelWrapper>
173
204
  )}
174
- PaperComponent={(props) => PaperComponent(props, loadingInternalOptions)}
205
+ PaperComponent={CustomPaper}
175
206
  renderOption={(props, option: any) => {
176
207
  return (
177
208
  <Box component="li" {...props}>
@@ -184,7 +215,11 @@ export const SingleSelect = ({
184
215
  }}
185
216
  ListboxProps={{
186
217
  onScroll: handleScroll,
187
- ref: listboxRef,
218
+ }}
219
+ slotProps={{
220
+ paper: {
221
+ square: loadingInternalOptions,
222
+ },
188
223
  }}
189
224
  onOpen={handleOpen}
190
225
  onClose={() => {
@@ -1,22 +1,14 @@
1
- import { motion } from "framer-motion";
2
- import { Spinner } from "../../Layout/Spinner/Spinner";
3
- import { Typography } from "../../Typography/Typography";
1
+ import { Typography } from "../../DataDisplay/Typography/Typography";
2
+ import { Spinner } from "../../FeedBack/Spinner/Spinner";
4
3
  import { FetchingOptionsLoaderContainer } from "../styles";
5
4
 
6
5
  export const FetchingOptionsLoader = ({ loading }: { loading: boolean }) => {
7
6
  return (
8
- <motion.div
9
- initial={{ display: loading ? "visible" : "none" }}
10
- animate={{
11
- display: loading ? "visible" : "none",
12
- opacity: loading ? 1 : 0,
13
- }}
14
- transition={{ delay: loading ? 1 : 0 }}
15
- >
7
+ loading && (
16
8
  <FetchingOptionsLoaderContainer direction="row" alignItems="center">
17
9
  <Spinner />
18
10
  <Typography variant="caption">Fetching Options</Typography>
19
11
  </FetchingOptionsLoaderContainer>
20
- </motion.div>
12
+ )
21
13
  );
22
- };
14
+ };
@@ -1,6 +1,6 @@
1
1
  import { IconButton } from "@mui/material";
2
2
  import { Meta, StoryObj } from "@storybook/react";
3
- import { DropdownMenuItem } from "../../DropDownMenu/DropdownMenuItem";
3
+ import { DropdownMenuItem } from "../../Navigation/DropDownMenu/DropdownMenuItem";
4
4
  import { Icons } from "../../export";
5
5
  import { AppHeader, AppHeaderProps } from "./AppHeader";
6
6
  import { AppsMenu } from "./AppsMenu";
@@ -1,6 +1,6 @@
1
1
  import { Divider, IconButton } from "@mui/material";
2
2
  import { ReactNode } from "react";
3
- import { DropdownMenu } from "../../../DropDownMenu/DropDownMenu";
3
+ import { DropdownMenu } from "../../../Navigation/DropDownMenu/DropDownMenu";
4
4
  import { Icons } from "../../../export";
5
5
  // import { clogWheel } from "../../../../assets/images";
6
6
  // import DropDownButton from "../../../DropDownButton/DropDownButton";