@campxdev/react-blueprint 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/DataDisplay/DataTable/TablePagination.tsx +5 -3
- package/src/components/FeedBack/Spinner/Spinner.css +32 -0
- package/src/components/{Layout → FeedBack}/Spinner/Spinner.stories.tsx +1 -1
- package/src/components/{Layout → FeedBack}/Spinner/Spinner.tsx +1 -1
- package/src/components/Icons/IconComponents/ActiveDevicesIcon.tsx +65 -0
- package/src/components/Icons/IconComponents/CheckedCheckBoxIcon.tsx +44 -0
- package/src/components/Icons/IconComponents/CheckedRadioIcon.tsx +44 -0
- package/src/components/Icons/IconComponents/DeviceIcon.tsx +58 -0
- package/src/components/Icons/IconComponents/ExportIcon.tsx +9 -2
- package/src/components/Icons/IconComponents/FilterIcon.tsx +9 -2
- package/src/components/Icons/IconComponents/InfoIcon.tsx +42 -0
- package/src/components/Icons/IconComponents/InstitutionsIcon.tsx +76 -0
- package/src/components/Icons/IconComponents/LocationIcon.tsx +50 -0
- package/src/components/Icons/IconComponents/NavigationIcon.tsx +30 -0
- package/src/components/Icons/IconComponents/ProfileIcon.tsx +49 -0
- package/src/components/Icons/IconComponents/TooltipIcon.tsx +26 -0
- package/src/components/Icons/IconComponents/UncheckCheckBoxIcon.tsx +28 -0
- package/src/components/Icons/IconComponents/UncheckedRadioIcon.tsx +28 -0
- package/src/components/Icons/export.ts +39 -14
- package/src/components/Input/Button/Button.tsx +1 -1
- package/src/components/Input/MultiCheckBox/MultiCheckBox.stories.tsx +46 -0
- package/src/components/Input/MultiCheckBox/MultiCheckBox.tsx +59 -0
- package/src/components/Input/RadioGroup/RadioGroup.stories.tsx +43 -0
- package/src/components/Input/RadioGroup/RadioGroup.tsx +56 -0
- package/src/components/Input/SingleCheckBox/SIngleCheckBox.tsx +33 -0
- package/src/components/Input/SingleCheckBox/SingleCheckBox.stories.tsx +33 -0
- package/src/components/Input/SingleSelect/SingleSelect.tsx +59 -24
- package/src/components/Input/components/FetchingOptionsLoader.tsx +5 -13
- package/src/components/Layout/Header/AppHeader.stories.tsx +1 -1
- package/src/components/Layout/Header/AppHeader.tsx +1 -1
- package/src/components/Layout/Header/HeaderActions/CogWheelMenu.tsx +1 -1
- package/src/components/Layout/Header/HeaderActions/UserBox.tsx +19 -10
- package/src/components/Layout/LayoutWrapper/styles.tsx +1 -1
- package/src/components/Layout/SideNavigation/SideNavigation.tsx +1 -1
- package/src/components/{DropDownMenu → Navigation/DropDownMenu}/DropDownButton.tsx +1 -1
- package/src/components/{DropDownMenu → Navigation/DropDownMenu}/DropDownMenu.stories.tsx +1 -1
- package/src/components/{TabsContainer → Navigation/TabsContainer}/TabsContainer.stories.tsx +1 -1
- package/src/components/export.ts +2 -2
- package/src/themes/commonTheme.ts +13 -1
- package/src/themes/darkTheme.ts +1 -0
- package/src/themes/lightTheme.ts +1 -0
- package/src/themes/typography.stories.tsx +1 -1
- package/src/utils/campxAxios.ts +1 -2
- package/src/utils/constants.ts +3 -0
- package/.vscode/settings.json +0 -3
- package/src/components/Layout/Spinner/Spinner.css +0 -32
- /package/src/components/{Typography → DataDisplay/Typography}/Typography.tsx +0 -0
- /package/src/components/{DropDownMenu → Navigation/DropDownMenu}/DropDownIcon.tsx +0 -0
- /package/src/components/{DropDownMenu → Navigation/DropDownMenu}/DropDownMenu.tsx +0 -0
- /package/src/components/{DropDownMenu → Navigation/DropDownMenu}/DropdownMenuItem.tsx +0 -0
- /package/src/components/{DropDownMenu → Navigation/DropDownMenu}/styles.tsx +0 -0
- /package/src/components/{TabsContainer → Navigation/TabsContainer}/TabsContainer.tsx +0 -0
|
@@ -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,30 +1,55 @@
|
|
|
1
|
+
import { ActiveDevicesIcon } from "./IconComponents/ActiveDevicesIcon";
|
|
1
2
|
import { AppsIcon } from "./IconComponents/AppsIcon";
|
|
2
3
|
import { CareerIcon } from "./IconComponents/CareerIcon";
|
|
4
|
+
import { CheckedCheckboxIcon } from "./IconComponents/CheckedCheckBoxIcon";
|
|
5
|
+
import { CheckedRadioIcon } from "./IconComponents/CheckedRadioIcon";
|
|
3
6
|
import { ClogWheelIcon } from "./IconComponents/ClogWheelIcon";
|
|
4
7
|
import { DashBoardIcon } from "./IconComponents/DashBoardIcon";
|
|
8
|
+
import { DeviceIcon } from "./IconComponents/DeviceIcon";
|
|
5
9
|
import { ExamResultIcon } from "./IconComponents/ExamResultIcon";
|
|
6
10
|
import { ExportIcon } from "./IconComponents/ExportIcon";
|
|
7
11
|
import { FilterIcon } from "./IconComponents/FilterIcon";
|
|
8
12
|
import { HelpIcon } from "./IconComponents/HelpIcon";
|
|
9
13
|
import { HomeIcon } from "./IconComponents/HomeIcon";
|
|
14
|
+
import { InfoIcon } from "./IconComponents/InfoIcon";
|
|
15
|
+
|
|
16
|
+
import { InstitutionsIcon } from "./IconComponents/InstitutionsIcon";
|
|
10
17
|
import { LeftIcon } from "./IconComponents/LeftIcon";
|
|
18
|
+
import { LocationIcon } from "./IconComponents/LocationIcon";
|
|
11
19
|
import { LogoutIcon } from "./IconComponents/LogoutIcon";
|
|
20
|
+
import { NavigationIcon } from "./IconComponents/NavigationIcon";
|
|
12
21
|
import { NotificationIcon } from "./IconComponents/NotificationIcon";
|
|
22
|
+
import { ProfileIcon } from "./IconComponents/ProfileIcon";
|
|
13
23
|
import { RightIcon } from "./IconComponents/RightIcon";
|
|
14
24
|
import { TicketsIcon } from "./IconComponents/TicketsIcon";
|
|
25
|
+
import { TooltipIcon } from "./IconComponents/TooltipIcon";
|
|
26
|
+
import { UnCheckedCheckboxIcon } from "./IconComponents/UncheckCheckBoxIcon";
|
|
27
|
+
import { UnCheckedRadioIcon } from "./IconComponents/UncheckedRadioIcon";
|
|
15
28
|
export const Icons = {
|
|
16
|
-
AppsIcon
|
|
17
|
-
CareerIcon
|
|
18
|
-
ClogWheelIcon
|
|
19
|
-
DashBoardIcon
|
|
20
|
-
HelpIcon
|
|
21
|
-
HomeIcon
|
|
22
|
-
LeftIcon
|
|
23
|
-
ExamResultIcon
|
|
24
|
-
NotificationIcon
|
|
25
|
-
RightIcon
|
|
26
|
-
LogoutIcon
|
|
27
|
-
TicketsIcon
|
|
28
|
-
FilterIcon
|
|
29
|
-
ExportIcon
|
|
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,
|
|
30
55
|
};
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "@mui/material";
|
|
5
5
|
import "./ButtonLoader.css";
|
|
6
6
|
|
|
7
|
-
export type ButtonProps = { loading
|
|
7
|
+
export type ButtonProps = { loading?: boolean } & MuiButtonProps;
|
|
8
8
|
|
|
9
9
|
export const Button = ({ loading = false, ...props }: ButtonProps) => {
|
|
10
10
|
return (
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Meta, StoryFn } from "@storybook/react";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { MultiCheckBox, MultiCheckboxProps } from "./MultiCheckBox";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: "Input/MultiCheckBox",
|
|
7
|
+
component: MultiCheckBox,
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
argTypes: {},
|
|
10
|
+
} as Meta<typeof MultiCheckBox>;
|
|
11
|
+
|
|
12
|
+
const MultiCheckBoxStory: StoryFn<MultiCheckboxProps> = (args) => {
|
|
13
|
+
const [defaultValues, setDefaultValues] = useState(args.values || []);
|
|
14
|
+
return (
|
|
15
|
+
<MultiCheckBox
|
|
16
|
+
{...args}
|
|
17
|
+
values={defaultValues}
|
|
18
|
+
onChange={(values: any) => {
|
|
19
|
+
setDefaultValues(values);
|
|
20
|
+
}}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Default = MultiCheckBoxStory.bind({});
|
|
26
|
+
Default.args = {
|
|
27
|
+
label: "First Name",
|
|
28
|
+
name: "firstName",
|
|
29
|
+
options: [
|
|
30
|
+
{
|
|
31
|
+
label: "Option 1",
|
|
32
|
+
value: "value1",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: "Option 2",
|
|
36
|
+
value: "value2",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: "Option 3",
|
|
40
|
+
value: "value3",
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
required: true,
|
|
44
|
+
direction: "row",
|
|
45
|
+
values: ["value2"],
|
|
46
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Stack, StackProps } from "@mui/material";
|
|
2
|
+
import { ResponsiveStyleValue } from "@mui/system";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { LabelWrapper } from "../LabelWrapper/LabelWrapper";
|
|
5
|
+
import { SingleCheckBox } from "../SingleCheckBox/SIngleCheckBox";
|
|
6
|
+
|
|
7
|
+
export type MultiCheckboxProps = {
|
|
8
|
+
containerProps?: StackProps;
|
|
9
|
+
options: Array<{ label: ReactNode; value: any }>;
|
|
10
|
+
label: string;
|
|
11
|
+
direction?: ResponsiveStyleValue<
|
|
12
|
+
"row" | "row-reverse" | "column" | "column-reverse"
|
|
13
|
+
>;
|
|
14
|
+
values: any[];
|
|
15
|
+
onChange: (values: any[]) => void;
|
|
16
|
+
required: boolean;
|
|
17
|
+
name: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const MultiCheckBox = ({
|
|
21
|
+
name,
|
|
22
|
+
options,
|
|
23
|
+
required = false,
|
|
24
|
+
containerProps,
|
|
25
|
+
label,
|
|
26
|
+
direction,
|
|
27
|
+
values = [],
|
|
28
|
+
onChange = () => {},
|
|
29
|
+
...rest
|
|
30
|
+
}: MultiCheckboxProps) => {
|
|
31
|
+
return (
|
|
32
|
+
<LabelWrapper
|
|
33
|
+
label={label}
|
|
34
|
+
required={required}
|
|
35
|
+
name={name}
|
|
36
|
+
containerProps={containerProps}
|
|
37
|
+
>
|
|
38
|
+
<Stack direction={direction}>
|
|
39
|
+
{options?.length != 0 &&
|
|
40
|
+
options?.map((item, index) => (
|
|
41
|
+
<SingleCheckBox
|
|
42
|
+
key={index}
|
|
43
|
+
name={name}
|
|
44
|
+
checked={values?.includes(item.value)}
|
|
45
|
+
label={item.label}
|
|
46
|
+
onChange={(event) => {
|
|
47
|
+
if (event.target.checked) {
|
|
48
|
+
onChange([...values, item.value]);
|
|
49
|
+
} else {
|
|
50
|
+
onChange(values.filter((val) => val !== item.value));
|
|
51
|
+
}
|
|
52
|
+
}}
|
|
53
|
+
{...rest}
|
|
54
|
+
/>
|
|
55
|
+
))}
|
|
56
|
+
</Stack>
|
|
57
|
+
</LabelWrapper>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
@@ -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
|
|
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 {
|
|
103
|
-
|
|
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
|
|
120
|
-
offset
|
|
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
|
-
|
|
167
|
+
listboxNode.scrollHeight - 1 &&
|
|
168
|
+
hasMore
|
|
154
169
|
) {
|
|
155
|
-
|
|
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:
|
|
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={
|
|
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
|
-
|
|
218
|
+
}}
|
|
219
|
+
slotProps={{
|
|
220
|
+
paper: {
|
|
221
|
+
square: loadingInternalOptions,
|
|
222
|
+
},
|
|
188
223
|
}}
|
|
189
224
|
onOpen={handleOpen}
|
|
190
225
|
onClose={() => {
|
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Spinner } from "../../
|
|
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
|
-
|
|
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
|
-
|
|
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";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Stack, Typography, useTheme } from "@mui/material";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
|
-
import { DropdownMenu } from "../../../DropDownMenu/DropDownMenu";
|
|
4
|
-
import { DropdownMenuItem } from "../../../DropDownMenu/DropdownMenuItem";
|
|
3
|
+
import { DropdownMenu } from "../../../Navigation/DropDownMenu/DropDownMenu";
|
|
4
|
+
import { DropdownMenuItem } from "../../../Navigation/DropDownMenu/DropdownMenuItem";
|
|
5
5
|
import { Icons } from "../../../export";
|
|
6
6
|
import { StyledAvatar, StyledTypography } from "../styles/styles";
|
|
7
7
|
// import {
|
|
@@ -63,16 +63,25 @@ export default function UserBox({
|
|
|
63
63
|
menu={[
|
|
64
64
|
<DropdownMenuItem
|
|
65
65
|
label={
|
|
66
|
-
<Stack gap={0.5}>
|
|
66
|
+
<Stack gap={0.5} sx={{ width: "100%" }}>
|
|
67
67
|
<StyledTypography variant="subtitle3">Account</StyledTypography>
|
|
68
|
-
<Stack
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
<
|
|
68
|
+
<Stack
|
|
69
|
+
direction={"row"}
|
|
70
|
+
alignItems={"center"}
|
|
71
|
+
justifyContent={"space-between"}
|
|
72
|
+
>
|
|
73
|
+
<Stack direction={"row"} gap={1}>
|
|
74
|
+
<StyledAvatar src={profileUrl ?? ""} sx={profileSx}>
|
|
75
|
+
{getStartingLetters(fullName)}
|
|
76
|
+
</StyledAvatar>
|
|
77
|
+
<Stack direction={"row"} justifyContent={"space-between"}>
|
|
78
|
+
<Stack>
|
|
79
|
+
<Typography variant="subtitle3">{fullName}</Typography>
|
|
80
|
+
<Typography variant="caption">{designation}</Typography>
|
|
81
|
+
</Stack>
|
|
82
|
+
</Stack>
|
|
75
83
|
</Stack>
|
|
84
|
+
<Icons.NavigationIcon />
|
|
76
85
|
</Stack>
|
|
77
86
|
</Stack>
|
|
78
87
|
}
|
|
@@ -2,7 +2,7 @@ import { ListItemIcon, Stack } from "@mui/material";
|
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
import { useMatch, useResolvedPath } from "react-router-dom";
|
|
4
4
|
import { activeStore } from "../../../store/activeStore";
|
|
5
|
-
import { Typography } from "../../Typography/Typography";
|
|
5
|
+
import { Typography } from "../../DataDisplay/Typography/Typography";
|
|
6
6
|
import { Icons } from "../../export";
|
|
7
7
|
import {
|
|
8
8
|
StyledBox,
|