@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 CHANGED
@@ -2,3 +2,4 @@ export * from './src/components/export';
2
2
  export * from './src/hooks/export';
3
3
  export * from './src/redux/export';
4
4
  export * from './src/themes/export';
5
+ export * from './src/utils/export';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campxdev/react-blueprint",
3
- "version": "1.5.7",
3
+ "version": "1.5.9",
4
4
  "main": "./export.ts",
5
5
  "private": false,
6
6
  "dependencies": {
@@ -1,4 +1,4 @@
1
- import { Box, Divider, InputAdornment, Stack, useTheme } from '@mui/material';
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" gap={1}>
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>
@@ -1,4 +1,5 @@
1
1
  export * from './AppHeader/AppHeader';
2
2
  export * from './PageContent/PageContent';
3
3
  export * from './PageHeader/components/DensitySelector/DensitySelector';
4
+ export * from './PageHeader/PageHeader';
4
5
  export * from './TabsLayout/TabsLayout';
@@ -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('/');
@@ -1 +1,3 @@
1
1
  export * from './usePageHeader';
2
+ export * from './useParams';
3
+ export * from './useUrlParams';
@@ -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] || ({} as PageHeaderState),
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,3 @@
1
+ export const useUrlParams = (): { [x: string]: string } => {
2
+ return Object.fromEntries(new URLSearchParams(window.location.search));
3
+ };
@@ -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
+ };
@@ -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 urlTenantKey = window.location.pathname.split('/')[1];
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';
@@ -0,0 +1,2 @@
1
+ export * from './breadcrumbs';
2
+ export * from './constants';
@@ -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
- }