@applica-software-guru/react-admin 1.5.295 → 1.5.296

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 CHANGED
@@ -106,5 +106,5 @@
106
106
  "type": "module",
107
107
  "types": "dist/index.d.ts",
108
108
  "typings": "dist/index.d.ts",
109
- "version": "1.5.295"
109
+ "version": "1.5.296"
110
110
  }
@@ -2,7 +2,7 @@ import { MainCard } from '@/components/MainCard';
2
2
  import { ListView } from '@/components/ra-lists/ListView';
3
3
  import { styled } from '@mui/system';
4
4
  import { ListBase, RaRecord } from 'ra-core';
5
- import { ReactElement } from 'react';
5
+ import React, { ReactElement } from 'react';
6
6
  import { ListProps } from 'react-admin';
7
7
  import { Pagination } from '@/components/Pagination/Pagination';
8
8
 
@@ -193,10 +193,12 @@ const StyledList = styled(RaList, { slot: 'root' })(({ theme }) => ({
193
193
  }));
194
194
 
195
195
  function List(props: ListProps): ReactElement {
196
+ const Wrapper = props.aside ? React.Fragment : MainCard;
197
+
196
198
  return (
197
- <MainCard content={false}>
199
+ <Wrapper {...(!props.aside && { content: false })}>
198
200
  <StyledList {...props} pagination={<Pagination />} />
199
- </MainCard>
201
+ </Wrapper>
200
202
  );
201
203
  }
202
204
 
@@ -1,14 +1,20 @@
1
1
  /* eslint-disable filenames/match-regex */
2
2
  import { Error } from '@/components/Layout/Error';
3
- import { Card } from '@mui/material';
4
- import { styled } from '@mui/material/styles';
3
+ import { Card, CardContent } from '@mui/material';
4
+ import { styled, useTheme } from '@mui/material/styles';
5
5
  import { SxProps } from '@mui/system';
6
6
  import clsx from 'clsx';
7
7
  import { RaRecord, useListContext } from 'ra-core';
8
8
  import { ElementType, ReactElement, ReactNode, cloneElement } from 'react';
9
9
  import * as React from 'react';
10
- import { ListActions as DefaultActions, Pagination as DefaultPagination, Empty, ListToolbar, Title } from 'react-admin';
11
-
10
+ import {
11
+ ListActions as DefaultActions,
12
+ Pagination as DefaultPagination,
13
+ Empty,
14
+ ListToolbar,
15
+ SavedQueriesListClasses,
16
+ Title
17
+ } from 'react-admin';
12
18
  const defaultActions = <DefaultActions />;
13
19
  const defaultPagination = <DefaultPagination />;
14
20
  const defaultEmpty = <Empty />;
@@ -31,6 +37,8 @@ function ListView<RecordType extends RaRecord = any>(props: ListViewProps): Reac
31
37
  ...rest
32
38
  } = props;
33
39
  const { defaultTitle, data, error, isLoading, filterValues, resource } = useListContext<RecordType>(props);
40
+ const theme = useTheme() as any;
41
+ const isAsideValidElement = React.isValidElement(aside);
34
42
 
35
43
  if (!children || (!data && isLoading && emptyWhileLoading)) {
36
44
  return null;
@@ -38,7 +46,19 @@ function ListView<RecordType extends RaRecord = any>(props: ListViewProps): Reac
38
46
 
39
47
  function renderList() {
40
48
  return (
41
- <div className={ListClasses.main}>
49
+ <div
50
+ className={ListClasses.main}
51
+ style={{
52
+ border: isAsideValidElement ? '1px solid' : 'none',
53
+ borderRadius: isAsideValidElement ? 4 : 0,
54
+ borderColor: isAsideValidElement
55
+ ? theme.palette.mode === 'dark'
56
+ ? theme.palette.divider
57
+ : theme.palette.grey.A800
58
+ : 'transparent',
59
+ backgroundColor: isAsideValidElement ? theme.palette.background.paper : 'transparent'
60
+ }}
61
+ >
42
62
  {filters || actions ? (
43
63
  <ListToolbar className={ListClasses.actions} filters={filters} actions={actions} hasCreate={hasCreate} />
44
64
  ) : null}
@@ -77,17 +97,46 @@ function ListView<RecordType extends RaRecord = any>(props: ListViewProps): Reac
77
97
  <Root className={clsx('list-page', className)} {...rest}>
78
98
  <Title title={title} defaultTitle={defaultTitle} preferenceKey={`${resource}.list.title`} />
79
99
  {shouldRenderEmptyPage ? renderEmpty() : renderList()}
80
- {aside}
100
+ {isAsideValidElement ? <AsideCard aside={aside} /> : null}
81
101
  </Root>
82
102
  );
83
103
  }
84
104
 
105
+ interface AsideCardProps {
106
+ aside: React.ReactElement;
107
+ }
108
+
109
+ function AsideCard({ aside }: AsideCardProps): ReactElement {
110
+ const order = (aside?.props as { order?: number })?.order ?? -1;
111
+ const theme = useTheme() as any;
112
+
113
+ return (
114
+ <Card
115
+ className={ListClasses.asideCard}
116
+ sx={{
117
+ order,
118
+ mr: order === -1 ? 2 : 0,
119
+ ml: order !== -1 ? 2 : 0,
120
+ width: 200,
121
+ border: '1px solid',
122
+ borderRadius: 1,
123
+ borderColor: theme.palette.mode === 'dark' ? theme.palette.divider : theme.palette.grey.A800,
124
+ backgroundColor: theme.palette.background.paper,
125
+ backgroundImage: 'none'
126
+ }}
127
+ >
128
+ <CardContent sx={{ pt: 1 }}>{cloneElement(aside, {})}</CardContent>
129
+ </Card>
130
+ );
131
+ }
132
+
85
133
  const PREFIX = 'RaList';
86
134
  const ListClasses = {
87
135
  main: `${PREFIX}-main`,
88
136
  content: `${PREFIX}-content`,
89
137
  actions: `${PREFIX}-actions`,
90
- noResults: `${PREFIX}-noResults`
138
+ noResults: `${PREFIX}-noResults`,
139
+ asideCard: `${PREFIX}-asideCard`
91
140
  };
92
141
 
93
142
  interface ListViewProps {
@@ -356,7 +405,22 @@ const Root = styled('div', {
356
405
 
357
406
  [`& .${ListClasses.actions}`]: {},
358
407
 
359
- [`& .${ListClasses.noResults}`]: {}
408
+ [`& .${ListClasses.noResults}`]: {},
409
+
410
+ [`& .${ListClasses.asideCard}`]: {
411
+ [theme.breakpoints.down('md')]: {
412
+ display: 'none'
413
+ },
414
+ [`& .${SavedQueriesListClasses.floatingIcon}`]: {
415
+ fontSize: '1.125rem'
416
+ },
417
+ [`& .${SavedQueriesListClasses.floatingTooltip}`]: {
418
+ top: '-1.2em'
419
+ },
420
+ '& form': {
421
+ marginTop: theme.spacing(2)
422
+ }
423
+ }
360
424
  }));
361
425
 
362
426
  export { ListView };
package/src/index.ts CHANGED
@@ -23,6 +23,9 @@ export {
23
23
  EditContextProvider,
24
24
  FieldTitle,
25
25
  FilterButton,
26
+ FilterList,
27
+ FilterListItem,
28
+ FilterLiveSearch,
26
29
  Form,
27
30
  FormDataConsumer,
28
31
  HttpError,
@@ -37,6 +40,7 @@ export {
37
40
  Resource,
38
41
  ResourceContextProvider,
39
42
  SaveButton,
43
+ SavedQueriesList,
40
44
  SimpleFormIteratorContext,
41
45
  SimpleShowLayout,
42
46
  SingleFieldList,