@campxdev/react-blueprint 1.5.6 → 1.5.8
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/Input/SingleSelect/SingleSelect.tsx +1 -1
- package/src/components/Navigation/Breadcrumbs/Breadcrumbs.tsx +2 -14
- package/src/hooks/export.ts +2 -0
- package/src/hooks/useParams.ts +20 -0
- package/src/hooks/useUrlParams.ts +3 -0
- package/src/themes/commonTheme.ts +4 -1
- 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
|
@@ -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
|
@@ -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
|
+
};
|
|
@@ -316,7 +316,7 @@ export const getCommonTheme = (mode: Theme) => {
|
|
|
316
316
|
},
|
|
317
317
|
},
|
|
318
318
|
'& input:-webkit-autofill': {
|
|
319
|
-
|
|
319
|
+
padding: '9px',
|
|
320
320
|
},
|
|
321
321
|
minWidth: '200px',
|
|
322
322
|
},
|
|
@@ -434,6 +434,9 @@ export const getCommonTheme = (mode: Theme) => {
|
|
|
434
434
|
fontWeight: 300,
|
|
435
435
|
color: ColorTokens.text.primary,
|
|
436
436
|
},
|
|
437
|
+
multiline: {
|
|
438
|
+
maxHeight: '200px',
|
|
439
|
+
},
|
|
437
440
|
},
|
|
438
441
|
},
|
|
439
442
|
MuiLink: {
|
|
@@ -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
|
-
}
|