@campxdev/react-blueprint 1.5.7 → 1.5.9
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/export.ts +1 -0
- package/package.json +1 -1
- package/src/components/Layout/PageHeader/PageHeader.tsx +7 -12
- package/src/components/Layout/export.ts +1 -0
- package/src/components/Navigation/Breadcrumbs/Breadcrumbs.tsx +2 -14
- package/src/hooks/export.ts +2 -0
- package/src/hooks/usePageHeader.ts +7 -5
- package/src/hooks/useParams.ts +20 -0
- package/src/hooks/useUrlParams.ts +3 -0
- package/src/utils/breadcrumbs.ts +23 -0
- package/src/utils/constants.ts +1 -5
- package/src/utils/export.ts +2 -0
- package/src/utils/logout.ts +0 -19
package/export.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Box, Divider,
|
|
1
|
+
import { Box, Divider, Stack, useTheme } from '@mui/material';
|
|
2
2
|
import { GridColDef } from '@mui/x-data-grid';
|
|
3
3
|
import { motion } from 'framer-motion';
|
|
4
4
|
import { ReactNode, useState } from 'react';
|
|
@@ -6,14 +6,9 @@ import {
|
|
|
6
6
|
DensitySelector,
|
|
7
7
|
Icons,
|
|
8
8
|
TableColumnsSelector,
|
|
9
|
-
TextField,
|
|
10
9
|
Typography,
|
|
11
10
|
} from '../../export';
|
|
12
|
-
import {
|
|
13
|
-
ColumnsAnchor,
|
|
14
|
-
FiltersAnchor,
|
|
15
|
-
SearchAnchor,
|
|
16
|
-
} from './components/Anchors';
|
|
11
|
+
import { ColumnsAnchor } from './components/Anchors';
|
|
17
12
|
|
|
18
13
|
interface PageHeaderProps {
|
|
19
14
|
uniqueId: string;
|
|
@@ -91,15 +86,15 @@ export const PageHeader = ({
|
|
|
91
86
|
justifyContent="space-between"
|
|
92
87
|
>
|
|
93
88
|
{columns ? <ViewTab title="Default View" /> : viewsSlot}
|
|
94
|
-
<Stack direction="row" alignItems="center"
|
|
95
|
-
{columns && (
|
|
89
|
+
<Stack direction="row" alignItems="center">
|
|
90
|
+
{/* {columns && (
|
|
96
91
|
<FiltersAnchor
|
|
97
92
|
handleClick={() => {
|
|
98
93
|
setExpanded(!expanded);
|
|
99
94
|
}}
|
|
100
95
|
showDot={false}
|
|
101
96
|
/>
|
|
102
|
-
)}
|
|
97
|
+
)} */}
|
|
103
98
|
{columns && (
|
|
104
99
|
<ColumnsAnchor
|
|
105
100
|
handleClick={() => {
|
|
@@ -108,7 +103,7 @@ export const PageHeader = ({
|
|
|
108
103
|
showDot={false}
|
|
109
104
|
/>
|
|
110
105
|
)}
|
|
111
|
-
<motion.div
|
|
106
|
+
{/* <motion.div
|
|
112
107
|
variants={motionTextFieldVariants}
|
|
113
108
|
animate={expandedSearch ? 'expanded' : 'collapsed'}
|
|
114
109
|
transition={{ duration: 0.3 }}
|
|
@@ -135,7 +130,7 @@ export const PageHeader = ({
|
|
|
135
130
|
autoFocus
|
|
136
131
|
/>
|
|
137
132
|
)}
|
|
138
|
-
</motion.div>
|
|
133
|
+
</motion.div> */}
|
|
139
134
|
{columns && <DensitySelector uniqueId={uniqueId} />}
|
|
140
135
|
{actions?.map((action, index) => action)}
|
|
141
136
|
</Stack>
|
|
@@ -6,26 +6,14 @@ import {
|
|
|
6
6
|
} from '@mui/material';
|
|
7
7
|
import _ from 'lodash';
|
|
8
8
|
import { Link } from 'react-router-dom';
|
|
9
|
+
|
|
10
|
+
import { getBreadcrumbsCharacter } from '../../../utils/export';
|
|
9
11
|
import { Typography } from '../../export';
|
|
10
12
|
|
|
11
13
|
export type BreadcrumbsProps = {
|
|
12
14
|
pathTrimCount: number;
|
|
13
15
|
} & MuiBreadcrumbsProps;
|
|
14
16
|
|
|
15
|
-
const getBreadcrumbsCharacter = () => {
|
|
16
|
-
const unicodeChar = String.fromCharCode(0x21e5);
|
|
17
|
-
const testElement = document.createElement('span');
|
|
18
|
-
testElement.innerHTML = unicodeChar;
|
|
19
|
-
document.body.appendChild(testElement);
|
|
20
|
-
const isRendered = testElement.offsetWidth > 0;
|
|
21
|
-
document.body.removeChild(testElement);
|
|
22
|
-
|
|
23
|
-
const fallbackChar = '~~';
|
|
24
|
-
const s = isRendered ? unicodeChar : fallbackChar;
|
|
25
|
-
|
|
26
|
-
return s;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
17
|
export const Breadcrumbs = ({ pathTrimCount, ...rest }: BreadcrumbsProps) => {
|
|
30
18
|
const specialCharacter = getBreadcrumbsCharacter();
|
|
31
19
|
const currentPathArray = window.location.pathname.split('/');
|
package/src/hooks/export.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
import { GridColumnVisibilityModel, GridDensity } from '@mui/x-data-grid';
|
|
1
2
|
import { useRef } from 'react';
|
|
2
3
|
import { useDispatch, useSelector } from 'react-redux';
|
|
3
4
|
import { v4 } from 'uuid';
|
|
4
|
-
import {
|
|
5
|
-
PageHeaderState,
|
|
6
|
-
resetStateForUniqueId,
|
|
7
|
-
} from '../redux/slices/pageHeaderSlice';
|
|
5
|
+
import { resetStateForUniqueId } from '../redux/slices/pageHeaderSlice';
|
|
8
6
|
import { RootState } from '../redux/store';
|
|
9
7
|
|
|
10
8
|
export const usePageHeader = () => {
|
|
@@ -12,7 +10,11 @@ export const usePageHeader = () => {
|
|
|
12
10
|
const dispatch = useDispatch();
|
|
13
11
|
const filterState = useSelector(
|
|
14
12
|
(state: RootState) =>
|
|
15
|
-
state.pageHeaderSlice[uuidRef.current] ||
|
|
13
|
+
state.pageHeaderSlice[uuidRef.current] ||
|
|
14
|
+
({} as {
|
|
15
|
+
density: GridDensity;
|
|
16
|
+
columnVisibilityModel: GridColumnVisibilityModel;
|
|
17
|
+
}),
|
|
16
18
|
);
|
|
17
19
|
|
|
18
20
|
const resetState = () => {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useParams as useReactRouterParams } from 'react-router-dom';
|
|
2
|
+
import { getBreadcrumbsCharacter } from '../utils/breadcrumbs';
|
|
3
|
+
|
|
4
|
+
export const useParams = (): {
|
|
5
|
+
[x: string]: { id: string | number; slug: string };
|
|
6
|
+
} => {
|
|
7
|
+
const params = useReactRouterParams();
|
|
8
|
+
|
|
9
|
+
const processedParams = Object.fromEntries(
|
|
10
|
+
Object.entries(params).map(([key, value]) => {
|
|
11
|
+
if (value) {
|
|
12
|
+
const [slug, id] = value.split(getBreadcrumbsCharacter());
|
|
13
|
+
return [key, { slug, id }];
|
|
14
|
+
}
|
|
15
|
+
return [];
|
|
16
|
+
}),
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
return processedParams;
|
|
20
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
|
|
3
|
+
export const getBreadcrumbsCharacter = () => {
|
|
4
|
+
const unicodeChar = String.fromCharCode(0x21e5);
|
|
5
|
+
const testElement = document.createElement('span');
|
|
6
|
+
testElement.innerHTML = unicodeChar;
|
|
7
|
+
document.body.appendChild(testElement);
|
|
8
|
+
const isRendered = testElement.offsetWidth > 0;
|
|
9
|
+
document.body.removeChild(testElement);
|
|
10
|
+
|
|
11
|
+
const fallbackChar = '~~';
|
|
12
|
+
const s = isRendered ? unicodeChar : fallbackChar;
|
|
13
|
+
|
|
14
|
+
return s;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type CreateUrlSlug = {
|
|
18
|
+
name: string;
|
|
19
|
+
id: string | number;
|
|
20
|
+
};
|
|
21
|
+
export const createBreadcrumbIdSlug = ({ name, id }: CreateUrlSlug): string => {
|
|
22
|
+
return `${_.kebabCase(name)}${getBreadcrumbsCharacter()}${id}`;
|
|
23
|
+
};
|
package/src/utils/constants.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import Cookies from 'js-cookie';
|
|
2
|
-
|
|
3
1
|
export const isDevelopment: boolean = process.env.NODE_ENV === 'development';
|
|
4
|
-
export const
|
|
5
|
-
export const institutionKey = window.location.pathname.split('/')[2];
|
|
6
|
-
export const sessionKey = Cookies.get('campx_session_key');
|
|
2
|
+
export const isLocal = window.location.hostname === 'localhost';
|
package/src/utils/logout.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import Cookies from 'js-cookie';
|
|
3
|
-
|
|
4
|
-
export default function logout() {
|
|
5
|
-
axios({
|
|
6
|
-
method: 'POST',
|
|
7
|
-
baseURL: process.env.REACT_APP_API_HOST,
|
|
8
|
-
url: '/auth-server/auth/logout',
|
|
9
|
-
})
|
|
10
|
-
.then((res) => {
|
|
11
|
-
Cookies.remove('campx_tenant');
|
|
12
|
-
Cookies.remove('campx_session_key');
|
|
13
|
-
Cookies.remove('campx_institution');
|
|
14
|
-
window.location.href = '/';
|
|
15
|
-
})
|
|
16
|
-
.catch((err) => {
|
|
17
|
-
// toast("Unable To Logout.");
|
|
18
|
-
});
|
|
19
|
-
}
|