@canmingir/link 1.2.0 → 1.2.2

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 (32) hide show
  1. package/package.json +1 -1
  2. package/src/layouts/common/ProjectBar/index.jsx +9 -8
  3. package/src/lib/CustomBreadcrumbs/CustomBreadcrumbs.jsx +88 -0
  4. package/src/lib/CustomBreadcrumbs/index.js +1 -0
  5. package/src/lib/CustomBreadcrumbs/link-item.jsx +58 -0
  6. package/src/lib/CustomPopover/CustomPopover.jsx +46 -0
  7. package/src/lib/CustomPopover/index.js +3 -0
  8. package/src/lib/CustomPopover/styles.js +82 -0
  9. package/src/lib/CustomPopover/usePopover.js +20 -0
  10. package/src/lib/CustomPopover/utils.js +100 -0
  11. package/src/lib/FormProvider/FormProvider.jsx +16 -0
  12. package/src/lib/FormProvider/index.js +1 -0
  13. package/src/lib/Image/Image.jsx +116 -0
  14. package/src/lib/Image/index.js +1 -0
  15. package/src/lib/Image/utils.js +15 -0
  16. package/src/lib/Label/Label.jsx +51 -0
  17. package/src/lib/Label/index.js +1 -0
  18. package/src/lib/Label/styles.js +76 -0
  19. package/src/lib/RHFTextfield/RHFTextfield.jsx +39 -0
  20. package/src/lib/RHFTextfield/index.js +1 -0
  21. package/src/lib/Scrollbar/Scrollbar.jsx +39 -0
  22. package/src/lib/Scrollbar/index.js +1 -0
  23. package/src/lib/Scrollbar/styles.js +27 -0
  24. package/src/lib/SearchNotFound/SearchNotFound.jsx +29 -0
  25. package/src/lib/SearchNotFound/index.js +1 -0
  26. package/src/lib/TableHeadCustom/TableHeadCustom.jsx +87 -0
  27. package/src/lib/TableHeadCustom/index.js +1 -0
  28. package/src/lib/TableSelectedAction/TableSelectedAction.jsx +72 -0
  29. package/src/lib/TableSelectedAction/index.js +1 -0
  30. package/src/lib/index.js +13 -0
  31. package/src/lib/useChart/useChart.js +179 -0
  32. package/src/lib/useTable/useTable.js +121 -0
@@ -0,0 +1,76 @@
1
+ import { alpha, styled } from "@mui/material/styles";
2
+
3
+ import Box from "@mui/material/Box";
4
+
5
+ export const StyledLabel = styled(Box)(({ theme, ownerState }) => {
6
+ const lightMode = theme.palette.mode === "light";
7
+
8
+ const filledVariant = ownerState.variant === "filled";
9
+
10
+ const outlinedVariant = ownerState.variant === "outlined";
11
+
12
+ const softVariant = ownerState.variant === "soft";
13
+
14
+ const defaultStyle = {
15
+ ...(ownerState.color === "default" && {
16
+ // FILLED
17
+ ...(filledVariant && {
18
+ color: lightMode ? theme.palette.common.white : theme.palette.grey[800],
19
+ backgroundColor: theme.palette.text.primary,
20
+ }),
21
+ // OUTLINED
22
+ ...(outlinedVariant && {
23
+ backgroundColor: "transparent",
24
+ color: theme.palette.text.primary,
25
+ border: `2px solid ${theme.palette.text.primary}`,
26
+ }),
27
+ // SOFT
28
+ ...(softVariant && {
29
+ color: theme.palette.text.secondary,
30
+ backgroundColor: alpha(theme.palette.grey[500], 0.16),
31
+ }),
32
+ }),
33
+ };
34
+
35
+ const colorStyle = {
36
+ ...(ownerState.color !== "default" && {
37
+ // FILLED
38
+ ...(filledVariant && {
39
+ color: theme.palette[ownerState.color].contrastText,
40
+ backgroundColor: theme.palette[ownerState.color].main,
41
+ }),
42
+ // OUTLINED
43
+ ...(outlinedVariant && {
44
+ backgroundColor: "transparent",
45
+ color: theme.palette[ownerState.color].main,
46
+ border: `2px solid ${theme.palette[ownerState.color].main}`,
47
+ }),
48
+ // SOFT
49
+ ...(softVariant && {
50
+ color: theme.palette[ownerState.color][lightMode ? "dark" : "light"],
51
+ backgroundColor: alpha(theme.palette[ownerState.color].main, 0.16),
52
+ }),
53
+ }),
54
+ };
55
+
56
+ return {
57
+ height: 24,
58
+ minWidth: 24,
59
+ lineHeight: 0,
60
+ borderRadius: 6,
61
+ cursor: "default",
62
+ alignItems: "center",
63
+ whiteSpace: "nowrap",
64
+ display: "inline-flex",
65
+ justifyContent: "center",
66
+ textTransform: "capitalize",
67
+ padding: theme.spacing(0, 0.75),
68
+ fontSize: theme.typography.pxToRem(12),
69
+ fontWeight: theme.typography.fontWeightBold,
70
+ transition: theme.transitions.create("all", {
71
+ duration: theme.transitions.duration.shorter,
72
+ }),
73
+ ...defaultStyle,
74
+ ...colorStyle,
75
+ };
76
+ });
@@ -0,0 +1,39 @@
1
+ import { Controller, useFormContext } from "react-hook-form";
2
+
3
+ import PropTypes from "prop-types";
4
+ import TextField from "@mui/material/TextField";
5
+
6
+ export default function RHFTextField({ name, helperText, type, ...other }) {
7
+ const { control } = useFormContext();
8
+
9
+ return (
10
+ <Controller
11
+ name={name}
12
+ control={control}
13
+ render={({ field, fieldState: { error } }) => (
14
+ <TextField
15
+ {...field}
16
+ fullWidth
17
+ type={type}
18
+ value={type === "number" && field.value === 0 ? "" : field.value}
19
+ onChange={(event) => {
20
+ if (type === "number") {
21
+ field.onChange(Number(event.target.value));
22
+ } else {
23
+ field.onChange(event.target.value);
24
+ }
25
+ }}
26
+ error={!!error}
27
+ helperText={error ? error?.message : helperText}
28
+ {...other}
29
+ />
30
+ )}
31
+ />
32
+ );
33
+ }
34
+
35
+ RHFTextField.propTypes = {
36
+ helperText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
37
+ name: PropTypes.string,
38
+ type: PropTypes.string,
39
+ };
@@ -0,0 +1 @@
1
+ export { default } from "./RHFTextfield";
@@ -0,0 +1,39 @@
1
+ import Box from "@mui/material/Box";
2
+ import React from "react";
3
+ import { forwardRef } from "react";
4
+
5
+ import { StyledRootScrollbar, StyledScrollbar } from "./styles";
6
+
7
+ const Scrollbar = forwardRef(({ children, sx, ...other }, ref) => {
8
+ const userAgent =
9
+ typeof navigator === "undefined" ? "SSR" : navigator.userAgent;
10
+ const mobile =
11
+ /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
12
+ userAgent
13
+ );
14
+
15
+ if (mobile) {
16
+ return (
17
+ <Box ref={ref} sx={{ overflow: "auto", ...sx }} {...other}>
18
+ {children}
19
+ </Box>
20
+ );
21
+ }
22
+
23
+ return (
24
+ <StyledRootScrollbar>
25
+ <StyledScrollbar
26
+ scrollableNodeProps={{
27
+ ref,
28
+ }}
29
+ clickOnTrack={false}
30
+ sx={sx}
31
+ {...other}
32
+ >
33
+ {children}
34
+ </StyledScrollbar>
35
+ </StyledRootScrollbar>
36
+ );
37
+ });
38
+
39
+ export default Scrollbar;
@@ -0,0 +1 @@
1
+ export { default } from "./scrollbar";
@@ -0,0 +1,27 @@
1
+ import SimpleBar from "simplebar-react";
2
+
3
+ import { alpha, styled } from "@mui/material/styles";
4
+
5
+ // ----------------------------------------------------------------------
6
+
7
+ export const StyledRootScrollbar = styled("div")(() => ({
8
+ flexGrow: 1,
9
+ height: "100%",
10
+ overflow: "hidden",
11
+ }));
12
+
13
+ export const StyledScrollbar = styled(SimpleBar)(({ theme }) => ({
14
+ maxHeight: "100%",
15
+
16
+ "& .simplebar-scrollbar": {
17
+ "&:before": {
18
+ backgroundColor: alpha(theme.palette.grey[600], 0.48),
19
+ },
20
+ "&.simplebar-visible:before": {
21
+ opacity: 1,
22
+ },
23
+ },
24
+ "& .simplebar-mask": {
25
+ zIndex: "inherit",
26
+ },
27
+ }));
@@ -0,0 +1,29 @@
1
+ import Paper from "@mui/material/Paper";
2
+ import Typography from "@mui/material/Typography";
3
+
4
+ export default function SearchNotFound({ query, sx, ...other }) {
5
+ return query ? (
6
+ <Paper
7
+ sx={{
8
+ bgcolor: "unset",
9
+ textAlign: "center",
10
+ ...sx,
11
+ }}
12
+ {...other}
13
+ >
14
+ <Typography variant="h6" gutterBottom>
15
+ Not Found
16
+ </Typography>
17
+
18
+ <Typography variant="body2">
19
+ No results found for &nbsp;
20
+ <strong>&quot;{query}&quot;</strong>.
21
+ <br /> Try checking for typos or using complete words.
22
+ </Typography>
23
+ </Paper>
24
+ ) : (
25
+ <Typography variant="body2" sx={sx}>
26
+ Please enter keywords
27
+ </Typography>
28
+ );
29
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./SearchNotFound";
@@ -0,0 +1,87 @@
1
+ import Box from "@mui/material/Box";
2
+ import Checkbox from "@mui/material/Checkbox";
3
+ import PropTypes from "prop-types";
4
+ import TableCell from "@mui/material/TableCell";
5
+ import TableHead from "@mui/material/TableHead";
6
+ import TableRow from "@mui/material/TableRow";
7
+ import TableSortLabel from "@mui/material/TableSortLabel";
8
+
9
+ const visuallyHidden = {
10
+ border: 0,
11
+ margin: -1,
12
+ padding: 0,
13
+ width: "1px",
14
+ height: "1px",
15
+ overflow: "hidden",
16
+ position: "absolute",
17
+ whiteSpace: "nowrap",
18
+ clip: "rect(0 0 0 0)",
19
+ };
20
+
21
+ export default function TableHeadCustom({
22
+ order,
23
+ orderBy,
24
+ rowCount = 0,
25
+ headLabel,
26
+ numSelected = 0,
27
+ onSort,
28
+ onSelectAllRows,
29
+ sx,
30
+ }) {
31
+ return (
32
+ <TableHead sx={sx}>
33
+ <TableRow>
34
+ {onSelectAllRows && (
35
+ <TableCell padding="checkbox">
36
+ <Checkbox
37
+ indeterminate={!!numSelected && numSelected < rowCount}
38
+ checked={!!rowCount && numSelected === rowCount}
39
+ onChange={(event) => onSelectAllRows(event.target.checked)}
40
+ />
41
+ </TableCell>
42
+ )}
43
+
44
+ {headLabel.map((headCell) => (
45
+ <TableCell
46
+ key={headCell.id}
47
+ align={headCell.align || "left"}
48
+ sortDirection={orderBy === headCell.id ? order : false}
49
+ sx={{ width: headCell.width, minWidth: headCell.minWidth }}
50
+ >
51
+ {onSort ? (
52
+ <TableSortLabel
53
+ hideSortIcon
54
+ active={orderBy === headCell.id}
55
+ direction={orderBy === headCell.id ? order : "asc"}
56
+ onClick={() => onSort(headCell.id)}
57
+ >
58
+ {headCell.label}
59
+
60
+ {orderBy === headCell.id ? (
61
+ <Box sx={{ ...visuallyHidden }}>
62
+ {order === "desc"
63
+ ? "sorted descending"
64
+ : "sorted ascending"}
65
+ </Box>
66
+ ) : null}
67
+ </TableSortLabel>
68
+ ) : (
69
+ headCell.label
70
+ )}
71
+ </TableCell>
72
+ ))}
73
+ </TableRow>
74
+ </TableHead>
75
+ );
76
+ }
77
+
78
+ TableHeadCustom.propTypes = {
79
+ sx: PropTypes.object,
80
+ onSort: PropTypes.func,
81
+ orderBy: PropTypes.string,
82
+ headLabel: PropTypes.array,
83
+ rowCount: PropTypes.number,
84
+ numSelected: PropTypes.number,
85
+ onSelectAllRows: PropTypes.func,
86
+ order: PropTypes.oneOf(["asc", "desc"]),
87
+ };
@@ -0,0 +1 @@
1
+ export { default } from "./TableHeadCustom";
@@ -0,0 +1,72 @@
1
+ import Checkbox from "@mui/material/Checkbox";
2
+ import PropTypes from "prop-types";
3
+ import Stack from "@mui/material/Stack";
4
+ import Typography from "@mui/material/Typography";
5
+
6
+ export default function TableSelectedAction({
7
+ dense,
8
+ action,
9
+ rowCount,
10
+ numSelected,
11
+ onSelectAllRows,
12
+ sx,
13
+ ...other
14
+ }) {
15
+ if (!numSelected) {
16
+ return null;
17
+ }
18
+
19
+ return (
20
+ <Stack
21
+ direction="row"
22
+ alignItems="center"
23
+ sx={{
24
+ pl: 1,
25
+ pr: 2,
26
+ top: 0,
27
+ left: 0,
28
+ width: 1,
29
+ zIndex: 9,
30
+ height: 58,
31
+ position: "absolute",
32
+ bgcolor: "primary.lighter",
33
+ ...(dense && {
34
+ height: 38,
35
+ }),
36
+ ...sx,
37
+ }}
38
+ {...other}
39
+ >
40
+ <Checkbox
41
+ indeterminate={!!numSelected && numSelected < rowCount}
42
+ checked={!!rowCount && numSelected === rowCount}
43
+ onChange={(event) => onSelectAllRows(event.target.checked)}
44
+ />
45
+
46
+ <Typography
47
+ variant="subtitle2"
48
+ sx={{
49
+ ml: 2,
50
+ flexGrow: 1,
51
+ color: "primary.main",
52
+ ...(dense && {
53
+ ml: 3,
54
+ }),
55
+ }}
56
+ >
57
+ {numSelected} selected
58
+ </Typography>
59
+
60
+ {action && action}
61
+ </Stack>
62
+ );
63
+ }
64
+
65
+ TableSelectedAction.propTypes = {
66
+ action: PropTypes.node,
67
+ dense: PropTypes.bool,
68
+ numSelected: PropTypes.number,
69
+ onSelectAllRows: PropTypes.func,
70
+ rowCount: PropTypes.number,
71
+ sx: PropTypes.object,
72
+ };
@@ -0,0 +1 @@
1
+ export { default } from "./TableSelectedAction";
package/src/lib/index.js CHANGED
@@ -8,3 +8,16 @@ export { default as SparkleInput } from "./SparkleInput/SparkleInput";
8
8
  export { default as StepComponent } from "./StepComponent/StepComponent";
9
9
  export { default as SvgColor } from "./SvgColor";
10
10
  export { default as ProjectWizard } from "./ProjectWizard";
11
+ export { default as CustomPopover } from "./CustomPopover/CustomPopover";
12
+ export { default as usePopover } from "./CustomPopover/usePopover";
13
+ export { default as Image } from "./Image/Image";
14
+ export { default as Label } from "./Label/Label";
15
+ export { default as Scrollbar } from "./Scrollbar/Scrollbar";
16
+ export { default as SearchNotFound } from "./SearchNotFound/SearchNotFound";
17
+ export { default as CustomBreadcrumbs } from "./CustomBreadcrumbs/CustomBreadcrumbs";
18
+ export { default as FormProvider } from "./FormProvider/FormProvider";
19
+ export { default as RHFTextField } from "./RHFTextfield/RHFTextfield";
20
+ export { default as TableHeadCustom } from "./TableHeadCustom/TableHeadCustom";
21
+ export { default as TableSelectedAction } from "./TableSelectedAction/TableSelectedAction";
22
+ export { default as useTable } from "./useTable/useTable";
23
+ export { default as useChart } from "./useChart/useChart";
@@ -0,0 +1,179 @@
1
+ import { alpha, useTheme } from "@mui/material/styles";
2
+
3
+ import merge from "lodash/merge";
4
+ import { useResponsive } from "src/hooks/use-responsive";
5
+
6
+ export default function useChart(options) {
7
+ const theme = useTheme();
8
+
9
+ const smUp = useResponsive("up", "sm");
10
+
11
+ const LABEL_TOTAL = {
12
+ show: true,
13
+ label: "Total",
14
+ color: theme.palette.text.secondary,
15
+ fontSize: theme.typography.subtitle2.fontSize,
16
+ fontWeight: theme.typography.subtitle2.fontWeight,
17
+ lineHeight: theme.typography.subtitle2.lineHeight,
18
+ };
19
+
20
+ const LABEL_VALUE = {
21
+ offsetY: 8,
22
+ color: theme.palette.text.primary,
23
+ fontSize: theme.typography.h3.fontSize,
24
+ fontWeight: theme.typography.h3.fontWeight,
25
+ lineHeight: theme.typography.h3.lineHeight,
26
+ };
27
+
28
+ const baseOptions = {
29
+ colors: [
30
+ theme.palette.primary.main,
31
+ theme.palette.warning.main,
32
+ theme.palette.info.main,
33
+ theme.palette.error.main,
34
+ theme.palette.success.main,
35
+ theme.palette.warning.dark,
36
+ theme.palette.success.darker,
37
+ theme.palette.info.dark,
38
+ theme.palette.info.darker,
39
+ ],
40
+
41
+ chart: {
42
+ toolbar: { show: false },
43
+ zoom: { enabled: false },
44
+ foreColor: theme.palette.text.disabled,
45
+ fontFamily: theme.typography.fontFamily,
46
+ },
47
+
48
+ states: {
49
+ hover: {
50
+ filter: {
51
+ type: "lighten",
52
+ value: 0.04,
53
+ },
54
+ },
55
+ active: {
56
+ filter: {
57
+ type: "darken",
58
+ value: 0.88,
59
+ },
60
+ },
61
+ },
62
+ fill: {
63
+ opacity: 1,
64
+ gradient: {
65
+ type: "vertical",
66
+ shadeIntensity: 0,
67
+ opacityFrom: 0.4,
68
+ opacityTo: 0,
69
+ stops: [0, 100],
70
+ },
71
+ },
72
+ dataLabels: {
73
+ enabled: false,
74
+ },
75
+ stroke: {
76
+ width: 3,
77
+ curve: "smooth",
78
+ lineCap: "round",
79
+ },
80
+ grid: {
81
+ strokeDashArray: 3,
82
+ borderColor: theme.palette.divider,
83
+ xaxis: {
84
+ lines: {
85
+ show: false,
86
+ },
87
+ },
88
+ },
89
+ xaxis: {
90
+ axisBorder: { show: false },
91
+ axisTicks: { show: false },
92
+ },
93
+ markers: {
94
+ size: 0,
95
+ strokeColors: theme.palette.background.paper,
96
+ },
97
+ tooltip: {
98
+ theme: false,
99
+ x: {
100
+ show: true,
101
+ },
102
+ },
103
+ legend: {
104
+ show: true,
105
+ fontSize: 13,
106
+ position: "top",
107
+ horizontalAlign: "right",
108
+ markers: {
109
+ radius: 12,
110
+ },
111
+ fontWeight: 500,
112
+ itemMargin: {
113
+ horizontal: 8,
114
+ },
115
+ labels: {
116
+ colors: theme.palette.text.primary,
117
+ },
118
+ },
119
+ plotOptions: {
120
+ bar: {
121
+ borderRadius: smUp ? 3 : 1,
122
+ columnWidth: "28%",
123
+ borderRadiusApplication: "end",
124
+ borderRadiusWhenStacked: "last",
125
+ },
126
+ pie: {
127
+ donut: {
128
+ labels: {
129
+ show: true,
130
+ value: LABEL_VALUE,
131
+ total: LABEL_TOTAL,
132
+ },
133
+ },
134
+ },
135
+
136
+ radialBar: {
137
+ track: {
138
+ strokeWidth: "100%",
139
+ background: alpha(theme.palette.grey[500], 0.16),
140
+ },
141
+ dataLabels: {
142
+ value: LABEL_VALUE,
143
+ total: LABEL_TOTAL,
144
+ },
145
+ },
146
+ radar: {
147
+ polygons: {
148
+ fill: { colors: ["transparent"] },
149
+ strokeColors: theme.palette.divider,
150
+ connectorColors: theme.palette.divider,
151
+ },
152
+ },
153
+ polarArea: {
154
+ rings: {
155
+ strokeColor: theme.palette.divider,
156
+ },
157
+ spokes: {
158
+ connectorColors: theme.palette.divider,
159
+ },
160
+ },
161
+ },
162
+ responsive: [
163
+ {
164
+ breakpoint: theme.breakpoints.values.sm,
165
+ options: {
166
+ plotOptions: { bar: { columnWidth: "40%" } },
167
+ },
168
+ },
169
+ {
170
+ breakpoint: theme.breakpoints.values.md,
171
+ options: {
172
+ plotOptions: { bar: { columnWidth: "32%" } },
173
+ },
174
+ },
175
+ ],
176
+ };
177
+
178
+ return merge(baseOptions, options);
179
+ }