@applica-software-guru/react-admin 1.5.228 → 1.5.230

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 (89) hide show
  1. package/.eslintrc +2 -1
  2. package/.husky/pre-commit +1 -1
  3. package/dist/components/@extended/AnimateButton.d.ts +3 -4
  4. package/dist/components/@extended/AnimateButton.d.ts.map +1 -1
  5. package/dist/components/@extended/Avatar.d.ts +3 -4
  6. package/dist/components/@extended/Avatar.d.ts.map +1 -1
  7. package/dist/components/@extended/IconButton.d.ts +10 -5
  8. package/dist/components/@extended/IconButton.d.ts.map +1 -1
  9. package/dist/components/@extended/LoadingButton.d.ts +12 -5
  10. package/dist/components/@extended/LoadingButton.d.ts.map +1 -1
  11. package/dist/components/@extended/Tooltip.d.ts +3 -4
  12. package/dist/components/@extended/Tooltip.d.ts.map +1 -1
  13. package/dist/components/@extended/Transitions.d.ts +7 -7
  14. package/dist/components/@extended/Transitions.d.ts.map +1 -1
  15. package/dist/components/ActionsMenu.d.ts +3 -4
  16. package/dist/components/ActionsMenu.d.ts.map +1 -1
  17. package/dist/components/AppStateProvider.d.ts +3 -2
  18. package/dist/components/AppStateProvider.d.ts.map +1 -1
  19. package/dist/components/AuthCard.d.ts +3 -5
  20. package/dist/components/AuthCard.d.ts.map +1 -1
  21. package/dist/components/AuthWrapper.d.ts +3 -4
  22. package/dist/components/AuthWrapper.d.ts.map +1 -1
  23. package/dist/components/Layout/MenuProvider.d.ts +4 -5
  24. package/dist/components/Layout/MenuProvider.d.ts.map +1 -1
  25. package/dist/components/Layout/Navigation/NavList.d.ts +3 -4
  26. package/dist/components/Layout/Navigation/NavList.d.ts.map +1 -1
  27. package/dist/components/Layout/ThemeProvider.d.ts +3 -4
  28. package/dist/components/Layout/ThemeProvider.d.ts.map +1 -1
  29. package/dist/components/MenuPopover/MenuPopover.d.ts +3 -4
  30. package/dist/components/MenuPopover/MenuPopover.d.ts.map +1 -1
  31. package/dist/components/ra-buttons/CreateInDialogButton.d.ts +3 -4
  32. package/dist/components/ra-buttons/CreateInDialogButton.d.ts.map +1 -1
  33. package/dist/components/ra-buttons/EditInDialogButton.d.ts +3 -4
  34. package/dist/components/ra-buttons/EditInDialogButton.d.ts.map +1 -1
  35. package/dist/components/ra-fields/ReadonlyField.d.ts +3 -4
  36. package/dist/components/ra-fields/ReadonlyField.d.ts.map +1 -1
  37. package/dist/components/ra-forms/CardForm.d.ts +5 -7
  38. package/dist/components/ra-forms/CardForm.d.ts.map +1 -1
  39. package/dist/components/ra-forms/Create.d.ts +5 -5
  40. package/dist/components/ra-forms/Create.d.ts.map +1 -1
  41. package/dist/components/ra-forms/TabbedForm.d.ts +2 -4
  42. package/dist/components/ra-forms/TabbedForm.d.ts.map +1 -1
  43. package/dist/components/ra-inputs/LabeledArrayInput.d.ts +3 -4
  44. package/dist/components/ra-inputs/LabeledArrayInput.d.ts.map +1 -1
  45. package/dist/components/ra-inputs/ReferenceArrayInput.d.ts +2 -4
  46. package/dist/components/ra-inputs/ReferenceArrayInput.d.ts.map +1 -1
  47. package/dist/components/ra-inputs/ReferenceInput.d.ts +2 -4
  48. package/dist/components/ra-inputs/ReferenceInput.d.ts.map +1 -1
  49. package/dist/components/ra-lists/Datagrid/DatagridContextProvider.d.ts +5 -4
  50. package/dist/components/ra-lists/Datagrid/DatagridContextProvider.d.ts.map +1 -1
  51. package/dist/react-admin.cjs.js +42 -42
  52. package/dist/react-admin.cjs.js.map +1 -1
  53. package/dist/react-admin.es.js +3400 -3405
  54. package/dist/react-admin.es.js.map +1 -1
  55. package/dist/react-admin.umd.js +45 -45
  56. package/dist/react-admin.umd.js.map +1 -1
  57. package/dist/themes/index.d.ts +0 -7
  58. package/dist/themes/index.d.ts.map +1 -1
  59. package/package.json +1 -1
  60. package/src/components/@extended/AnimateButton.tsx +3 -3
  61. package/src/components/@extended/Avatar.tsx +3 -3
  62. package/src/components/@extended/IconButton.tsx +5 -7
  63. package/src/components/@extended/LoadingButton.tsx +5 -7
  64. package/src/components/@extended/Tooltip.tsx +5 -6
  65. package/src/components/@extended/Transitions.tsx +3 -4
  66. package/src/components/ActionsMenu.tsx +2 -5
  67. package/src/components/AppStateProvider.tsx +6 -2
  68. package/src/components/AuthCard.tsx +4 -5
  69. package/src/components/AuthWrapper.tsx +3 -4
  70. package/src/components/Layout/MenuProvider.tsx +4 -5
  71. package/src/components/Layout/Navigation/NavList.tsx +2 -4
  72. package/src/components/Layout/ThemeProvider.tsx +3 -5
  73. package/src/components/MenuPopover/MenuPopover.tsx +3 -4
  74. package/src/components/ra-buttons/CreateInDialogButton.tsx +68 -65
  75. package/src/components/ra-buttons/EditInDialogButton.tsx +25 -22
  76. package/src/components/ra-fields/ReadonlyField.tsx +16 -14
  77. package/src/components/ra-forms/CardForm.tsx +9 -10
  78. package/src/components/ra-forms/Create.tsx +7 -7
  79. package/src/components/ra-forms/TabbedForm.tsx +4 -4
  80. package/src/components/ra-inputs/LabeledArrayInput.tsx +3 -4
  81. package/src/components/ra-inputs/ReferenceArrayInput.tsx +6 -7
  82. package/src/components/ra-inputs/ReferenceInput.tsx +5 -6
  83. package/src/components/ra-lists/Datagrid/DatagridContextProvider.tsx +5 -8
  84. package/src/playground/.prettierrc +1 -1
  85. package/src/playground/components/pages/CustomPage.jsx +6 -1
  86. package/src/playground/components/ra-forms/DeviceForm.jsx +8 -1
  87. package/src/playground/components/ra-lists/DeviceList.jsx +9 -1
  88. package/src/playground/components/ra-lists/I18nMessageList.jsx +9 -1
  89. package/src/themes/index.tsx +0 -6
@@ -3,7 +3,7 @@ import { useSx } from '@/hooks';
3
3
  import { InputLabel, Tooltip, Typography } from '@mui/material';
4
4
  import { styled } from '@mui/material/styles';
5
5
  import { get } from 'lodash';
6
- import React, { useMemo } from 'react';
6
+ import React, { Children, PropsWithChildren, useMemo } from 'react';
7
7
  import { FieldTitle, useRecordContext, useResourceContext } from 'react-admin';
8
8
 
9
9
  type StyledFieldProps = {
@@ -39,10 +39,9 @@ function BasicField({ source, defaultValue = ' ', ...props }: BasicFieldPro
39
39
  return <Typography {...props} dangerouslySetInnerHTML={{ __html: value && value !== null ? value : defaultValue }} />;
40
40
  }
41
41
 
42
- type ContentWrapperProps = {
42
+ type ContentWrapperProps = PropsWithChildren<{
43
43
  title: string | boolean;
44
- children: React.ReactNode;
45
- };
44
+ }>;
46
45
 
47
46
  function ContentWrapper({ title, children }: ContentWrapperProps): JSX.Element | null {
48
47
  if (children === null || children === undefined) return null;
@@ -64,6 +63,7 @@ function ReadonlyField({
64
63
  tooltip: _tooltip,
65
64
  ...props
66
65
  }: ReadonlyFieldProps): JSX.Element {
66
+ const Child = Children.only(children);
67
67
  const { getCurrentDialog } = useAppState();
68
68
  const record = useRecordContext(props);
69
69
  const resource = useResourceContext(props as any);
@@ -87,28 +87,30 @@ function ReadonlyField({
87
87
  <FieldTitle label={label} source={source} resource={dialogResource || resource} />
88
88
  </InputLabel>
89
89
  <StyledField {...props}>
90
- {React.cloneElement(children, {
91
- source,
92
- record,
93
- defaultValue,
94
- resource: dialogResource || resource,
95
- sx
96
- })}
90
+ {React.isValidElement(Child)
91
+ ? React.cloneElement(Child, {
92
+ ...Child.props,
93
+ source,
94
+ record,
95
+ defaultValue,
96
+ resource: dialogResource || resource,
97
+ sx
98
+ })
99
+ : null}
97
100
  </StyledField>
98
101
  </>
99
102
  </ContentWrapper>
100
103
  );
101
104
  }
102
105
 
103
- type ReadonlyFieldProps = {
106
+ type ReadonlyFieldProps = PropsWithChildren<{
104
107
  defaultValue: any;
105
108
  tooltip: string | boolean | ((record: any) => string);
106
109
  source: string;
107
110
  label: string;
108
111
  name: string;
109
- children: React.ReactElement<any, any>;
110
112
  fullWidth?: boolean;
111
- };
113
+ }>;
112
114
 
113
115
  export { ReadonlyField };
114
116
  export type { ReadonlyFieldProps };
@@ -3,7 +3,7 @@ import { MainCard } from '@/components/MainCard';
3
3
  import { Toolbar } from '@/components/ra-forms/Toolbar';
4
4
  import { Grid, GridProps } from '@mui/material';
5
5
  import { styled } from '@mui/material/styles';
6
- import React, { useMemo } from 'react';
6
+ import React, { PropsWithChildren, useMemo } from 'react';
7
7
  import { Form, SaveButton, useResourceContext, useTranslate } from 'react-admin';
8
8
 
9
9
  /**
@@ -65,12 +65,11 @@ function Section({
65
65
  );
66
66
  }
67
67
 
68
- type StyledFormProps = {
69
- children: React.ReactNode;
68
+ type StyledFormProps = PropsWithChildren<{
70
69
  spacing?: number;
71
70
  defaultValues?: any;
72
71
  theme: any;
73
- };
72
+ }>;
74
73
 
75
74
  const StyledForm = styled(Form, { slot: 'root' })(({ theme, spacing }: StyledFormProps) => ({
76
75
  backgroundColor: 'transparent',
@@ -87,20 +86,20 @@ const StyledForm = styled(Form, { slot: 'root' })(({ theme, spacing }: StyledFor
87
86
  }
88
87
  }));
89
88
 
90
- type CardFormProps = {
91
- children: React.ReactNode;
89
+ type CardFormProps = PropsWithChildren<{
92
90
  spacing?: number;
93
91
  defaultValues?: any;
94
- } & GridProps;
92
+ }> &
93
+ GridProps;
95
94
 
96
- type SectionProps = {
97
- children: React.ReactNode;
95
+ type SectionProps = PropsWithChildren<{
98
96
  content?: boolean | undefined | null;
99
97
  title?: string | React.ReactNode | null;
100
98
  subheader?: string | React.ReactNode;
101
99
  secondary?: string | React.ReactNode;
102
100
  toolbar?: React.ReactNode | boolean;
103
- } & GridProps;
101
+ }> &
102
+ GridProps;
104
103
 
105
104
  CardForm.Section = Section;
106
105
 
@@ -2,7 +2,7 @@
2
2
  import { CircularProgress, Stack } from '@mui/material';
3
3
  import { Theme, styled } from '@mui/material/styles';
4
4
  import _ from 'lodash';
5
- import { createContext, useCallback, useContext, useMemo } from 'react';
5
+ import { PropsWithChildren, createContext, useCallback, useContext, useMemo } from 'react';
6
6
  import {
7
7
  CreateProps,
8
8
  Identifier,
@@ -17,11 +17,11 @@ import { useLocation } from 'react-router';
17
17
  type ICreateProps<
18
18
  RecordType extends Omit<RaRecord, 'id'> = any,
19
19
  ResultRecordType extends RaRecord = RecordType & { id: Identifier }
20
- > = CreateProps<RecordType, Error, ResultRecordType> & {
21
- children: React.ReactNode;
22
- useDefaults?: boolean;
23
- queryOptions?: UseQueryOptions;
24
- };
20
+ > = CreateProps<RecordType, Error, ResultRecordType> &
21
+ PropsWithChildren<{
22
+ useDefaults?: boolean;
23
+ queryOptions?: UseQueryOptions;
24
+ }>;
25
25
 
26
26
  type IResourceDefaultValue = object;
27
27
  const ResourceDefaultValueContext = createContext<IResourceDefaultValue>({});
@@ -70,7 +70,7 @@ function CreateWithDefaults(props: ICreateProps) {
70
70
  </Stack>
71
71
  ) : (
72
72
  <ResourceDefaultValueContext.Provider value={data ?? {}}>
73
- <RaCreate {...passProps} />
73
+ <RaCreate {...(passProps as CreateProps)}>{props.children}</RaCreate>
74
74
  </ResourceDefaultValueContext.Provider>
75
75
  );
76
76
  }
@@ -4,6 +4,7 @@ import { Toolbar } from '@/components/ra-forms/Toolbar';
4
4
  import { useResourceTitle } from '@/hooks';
5
5
  import { Box, useTheme } from '@mui/material';
6
6
  import { styled } from '@mui/system';
7
+ import { PropsWithChildren } from 'react';
7
8
  import {
8
9
  DeleteWithConfirmButton,
9
10
  TabbedForm as RaTabbedForm,
@@ -12,9 +13,7 @@ import {
12
13
  TabProps
13
14
  } from 'react-admin';
14
15
 
15
- type StackTabProps = TabProps & {
16
- children: React.ReactNode;
17
- };
16
+ type StackTabProps = TabProps & PropsWithChildren<Record<string, never>>;
18
17
 
19
18
  const StyledTabbedForm = styled(RaTabbedForm, { slot: 'Root' })(({ theme }: { theme: any }) => ({
20
19
  '& .MuiGrid-root.MuiGrid-container': {
@@ -28,7 +27,8 @@ const StyledTabbedForm = styled(RaTabbedForm, { slot: 'Root' })(({ theme }: { th
28
27
  }
29
28
  }));
30
29
 
31
- function TabbedFormWithNoPadding({ children }: { children: React.ReactNode }): JSX.Element {
30
+ type TabbedFormWithNoPaddingProps = PropsWithChildren<Record<string, never>>;
31
+ function TabbedFormWithNoPadding({ children }: TabbedFormWithNoPaddingProps): JSX.Element {
32
32
  return <>{children}</>;
33
33
  }
34
34
 
@@ -1,7 +1,7 @@
1
1
  import { useAppConfig } from '@/components/AppStateProvider';
2
2
  import { useTheme } from '@emotion/react';
3
3
  import { FormHelperText, InputLabel, Stack, SxProps } from '@mui/material';
4
- import React from 'react';
4
+ import React, { PropsWithChildren } from 'react';
5
5
  import { FieldTitle } from 'react-admin';
6
6
  import { useFormContext } from 'react-hook-form';
7
7
 
@@ -80,7 +80,7 @@ function LabeledArrayInput({
80
80
  );
81
81
  }
82
82
 
83
- type LabeledArrayInputProps = {
83
+ type LabeledArrayInputProps = PropsWithChildren<{
84
84
  label?: string | boolean;
85
85
  addLabel?: boolean;
86
86
  resource?: string;
@@ -90,9 +90,8 @@ type LabeledArrayInputProps = {
90
90
  helperText?: string | boolean;
91
91
  divider?: boolean;
92
92
  sx?: SxProps;
93
- children: React.ReactElement;
94
93
  fullWidth?: boolean;
95
- };
94
+ }>;
96
95
 
97
96
  export { LabeledArrayInput };
98
97
  export type { LabeledArrayInputProps };
@@ -1,23 +1,22 @@
1
- import React from 'react';
1
+ import React, { Children } from 'react';
2
2
  import {
3
3
  ReferenceArrayInput as RaReferenceArrayInput,
4
4
  ReferenceArrayInputProps as RaReferenceArrayInputProps
5
5
  } from 'react-admin';
6
6
 
7
+ type ReferenceArrayInputProps = RaReferenceArrayInputProps;
8
+
7
9
  function ReferenceArrayInput({ children, ...props }: ReferenceArrayInputProps): JSX.Element {
10
+ const Child = Children.only(children);
8
11
  return (
9
12
  <RaReferenceArrayInput {...props}>
10
- {React.cloneElement(children, {
13
+ {React.cloneElement(Child!, {
11
14
  ...props,
12
- source: children.props.source || props.source
15
+ source: Child!.props.source || props.source
13
16
  })}
14
17
  </RaReferenceArrayInput>
15
18
  );
16
19
  }
17
20
 
18
- type ReferenceArrayInputProps = {
19
- children: React.ReactElement;
20
- } & RaReferenceArrayInputProps;
21
-
22
21
  export { ReferenceArrayInput };
23
22
  export type { ReferenceArrayInputProps };
@@ -1,16 +1,15 @@
1
- import React from 'react';
1
+ import React, { Children, PropsWithChildren } from 'react';
2
2
  import { ReferenceInput as RaReferenceInput, ReferenceInputProps as RaReferenceInputProps } from 'react-admin';
3
3
 
4
- type ReferenceInputProps = {
5
- children: React.ReactElement;
6
- } & RaReferenceInputProps;
4
+ type ReferenceInputProps = PropsWithChildren<Record<string, never>> & RaReferenceInputProps;
7
5
 
8
6
  function ReferenceInput({ children, ...props }: ReferenceInputProps): JSX.Element {
7
+ const Child = Children.only(children);
9
8
  return (
10
9
  <RaReferenceInput {...props}>
11
- {React.cloneElement(children, {
10
+ {React.cloneElement(Child!, {
12
11
  ...props,
13
- source: children.props.source || props.source
12
+ source: Child!.props.source || props.source
14
13
  })}
15
14
  </RaReferenceInput>
16
15
  );
@@ -1,13 +1,10 @@
1
1
  import { DatagridContext, DatagridContextValue } from './DatagridContext';
2
- import { ReactElement, ReactNode } from 'react';
2
+ import { PropsWithChildren, ReactElement } from 'react';
3
3
 
4
- function DatagridContextProvider({
5
- children,
6
- value
7
- }: {
8
- children: ReactNode;
9
- value: DatagridContextValue;
10
- }): ReactElement {
4
+ type DatagridContextProviderProps = PropsWithChildren<{ value: DatagridContextValue }>;
5
+
6
+ function DatagridContextProvider({ children, value }: DatagridContextProviderProps): ReactElement {
11
7
  return <DatagridContext.Provider value={value}>{children}</DatagridContext.Provider>;
12
8
  }
13
9
  export { DatagridContextProvider };
10
+ export type { DatagridContextProviderProps };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "bracketSpacing": true,
3
- "printWidth": 140,
3
+ "printWidth": 120,
4
4
  "singleQuote": true,
5
5
  "trailingComma": "none",
6
6
  "tabWidth": 2,
@@ -1,4 +1,9 @@
1
- import { OnboardingModes, OnboardingProvider, OnboardingTip, useRestartOnboarding } from '@applica-software-guru/react-admin';
1
+ import {
2
+ OnboardingModes,
3
+ OnboardingProvider,
4
+ OnboardingTip,
5
+ useRestartOnboarding
6
+ } from '@applica-software-guru/react-admin';
2
7
  import { Button, Stack, Typography } from '@mui/material';
3
8
 
4
9
  function CustomPage() {
@@ -1,4 +1,11 @@
1
- import { ReadonlyField, SimpleForm, TextInput, required, useRecordContext, useThemeConfig } from '@applica-software-guru/react-admin';
1
+ import {
2
+ ReadonlyField,
3
+ SimpleForm,
4
+ TextInput,
5
+ required,
6
+ useRecordContext,
7
+ useThemeConfig
8
+ } from '@applica-software-guru/react-admin';
2
9
  import { Grid } from '@mui/material';
3
10
 
4
11
  function DeviceForm() {
@@ -1,4 +1,12 @@
1
- import { Datagrid, DateField, List, SearchInput, TextField, useThemeConfig, useTranslate } from '@applica-software-guru/react-admin';
1
+ import {
2
+ Datagrid,
3
+ DateField,
4
+ List,
5
+ SearchInput,
6
+ TextField,
7
+ useThemeConfig,
8
+ useTranslate
9
+ } from '@applica-software-guru/react-admin';
2
10
  import { Alert } from '@mui/material';
3
11
 
4
12
  function AlertBox() {
@@ -1,4 +1,12 @@
1
- import { ActionsField, BooleanField, Datagrid, List, RecordInput, SearchInput, TextField } from '@applica-software-guru/react-admin';
1
+ import {
2
+ ActionsField,
3
+ BooleanField,
4
+ Datagrid,
5
+ List,
6
+ RecordInput,
7
+ SearchInput,
8
+ TextField
9
+ } from '@applica-software-guru/react-admin';
2
10
 
3
11
  function I18nMessageList() {
4
12
  return (
@@ -9,7 +9,6 @@ import { ThemeProps } from '@/themes/types';
9
9
  import { CssBaseline, StyledEngineProvider } from '@mui/material';
10
10
  import { ThemeProvider, createTheme } from '@mui/material/styles';
11
11
  import _ from 'lodash';
12
- import PropTypes from 'prop-types';
13
12
  import { PropsWithChildren, useMemo } from 'react';
14
13
 
15
14
  type ThemeCustomizationProps = PropsWithChildren<{ themeOverrides: unknown }>;
@@ -81,9 +80,4 @@ function ThemeCustomization({ themeOverrides, children }: ThemeCustomizationProp
81
80
  );
82
81
  }
83
82
 
84
- ThemeCustomization.propTypes = {
85
- children: PropTypes.node,
86
- themeOverrides: PropTypes.oneOfType([PropTypes.object, PropTypes.func])
87
- };
88
-
89
83
  export { ThemeCustomization, getColors as getThemeColor, getShadow as getThemeShadow };