@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
@@ -1,16 +1,9 @@
1
1
  import { getColors } from './getColors';
2
2
  import { getShadow } from './getShadow';
3
- import PropTypes from 'prop-types';
4
3
  import { PropsWithChildren } from 'react';
5
4
  type ThemeCustomizationProps = PropsWithChildren<{
6
5
  themeOverrides: unknown;
7
6
  }>;
8
7
  declare function ThemeCustomization({ themeOverrides, children }: ThemeCustomizationProps): import("react/jsx-runtime").JSX.Element;
9
- declare namespace ThemeCustomization {
10
- var propTypes: {
11
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
12
- themeOverrides: PropTypes.Requireable<object>;
13
- };
14
- }
15
8
  export { ThemeCustomization, getColors as getThemeColor, getShadow as getThemeShadow };
16
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/themes/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAUxC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAEnD,KAAK,uBAAuB,GAAG,iBAAiB,CAAC;IAAE,cAAc,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAE9E,iBAAS,kBAAkB,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,uBAAuB,2CAiEhF;kBAjEQ,kBAAkB;;;;;;AAwE3B,OAAO,EAAE,kBAAkB,EAAE,SAAS,IAAI,aAAa,EAAE,SAAS,IAAI,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/themes/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAUxC,OAAO,EAAE,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAEnD,KAAK,uBAAuB,GAAG,iBAAiB,CAAC;IAAE,cAAc,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAE9E,iBAAS,kBAAkB,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,uBAAuB,2CAiEhF;AAED,OAAO,EAAE,kBAAkB,EAAE,SAAS,IAAI,aAAa,EAAE,SAAS,IAAI,cAAc,EAAE,CAAC"}
package/package.json CHANGED
@@ -114,5 +114,5 @@
114
114
  "type": "module",
115
115
  "types": "dist/index.d.ts",
116
116
  "typings": "dist/index.d.ts",
117
- "version": "1.5.228"
117
+ "version": "1.5.230"
118
118
  }
@@ -1,12 +1,12 @@
1
1
  import { motion, useCycle } from 'framer-motion';
2
+ import { PropsWithChildren } from 'react';
2
3
 
3
- type AnimateButtonProps = {
4
- children: React.ReactNode;
4
+ type AnimateButtonProps = PropsWithChildren<{
5
5
  type?: 'rotate' | 'slide' | 'scale';
6
6
  direction?: 'up' | 'down' | 'left' | 'right';
7
7
  offset?: number;
8
8
  scale?: number | { hover: number; tap: number };
9
- };
9
+ }>;
10
10
 
11
11
  function AnimateButton({
12
12
  children,
@@ -1,6 +1,7 @@
1
1
  import { getColors } from '@/themes/getColors';
2
2
  import { default as MuiAvatar } from '@mui/material/Avatar';
3
3
  import { Theme, styled, useTheme } from '@mui/material/styles';
4
+ import { PropsWithChildren } from 'react';
4
5
 
5
6
  type GetColorStyleProps = {
6
7
  theme: any;
@@ -101,13 +102,12 @@ const AvatarStyle = styled(MuiAvatar, {
101
102
  })
102
103
  }));
103
104
 
104
- type AvatarProps = {
105
- children: React.ReactNode;
105
+ type AvatarProps = PropsWithChildren<{
106
106
  color: string;
107
107
  type: 'filled' | 'outlined' | 'combined';
108
108
  size: 'badge' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
109
109
  variant: 'circular' | 'rounded' | 'square';
110
- };
110
+ }>;
111
111
 
112
112
  function Avatar({ variant = 'circular', children, color = 'primary', type, size = 'md', ...others }: AvatarProps) {
113
113
  const theme = useTheme();
@@ -2,7 +2,7 @@ import { getColors } from '@/themes/getColors';
2
2
  import { getShadow } from '@/themes/getShadow';
3
3
  import { default as MuiIconButton } from '@mui/material/IconButton';
4
4
  import { Theme, alpha, styled, useTheme } from '@mui/material/styles';
5
- import { forwardRef } from 'react';
5
+ import { PropsWithChildren, forwardRef } from 'react';
6
6
 
7
7
  type GetColorStyleProps = {
8
8
  variant: string;
@@ -91,13 +91,12 @@ function getColorStyle({ variant, theme, color }: GetColorStyleProps) {
91
91
  }
92
92
  }
93
93
 
94
- type IconButtonStyleProps = {
94
+ type IconButtonStyleProps = PropsWithChildren<{
95
95
  variant: string;
96
96
  shape: string;
97
- children: React.ReactNode;
98
97
  color: string;
99
98
  theme: Theme;
100
- };
99
+ }>;
101
100
 
102
101
  const IconButtonStyle = styled(MuiIconButton, {
103
102
  shouldForwardProp: (prop) => prop !== 'variant' && prop !== 'shape'
@@ -143,12 +142,11 @@ const IconButtonStyle = styled(MuiIconButton, {
143
142
  ...getColorStyle({ variant, theme, color })
144
143
  }));
145
144
 
146
- type IconButtonProps = {
145
+ type IconButtonProps = PropsWithChildren<{
147
146
  variant?: string;
148
147
  shape?: string;
149
- children: React.ReactNode;
150
148
  color?: string;
151
- };
149
+ }>;
152
150
 
153
151
  const IconButton = forwardRef(
154
152
  ({ variant = 'text', shape = 'square', children, color = 'primary', ...others }: IconButtonProps, ref) => {
@@ -2,7 +2,7 @@ import { getColors } from '@/themes/getColors';
2
2
  import { getShadow } from '@/themes/getShadow';
3
3
  import { default as MuiLoadingButton } from '@mui/lab/LoadingButton';
4
4
  import { Theme, alpha, styled, useTheme } from '@mui/material/styles';
5
- import { forwardRef } from 'react';
5
+ import { PropsWithChildren, forwardRef } from 'react';
6
6
 
7
7
  type GetColorStyleProps = {
8
8
  variant: string;
@@ -121,15 +121,14 @@ function getColorStyle({ variant, theme, color, loadingPosition }: GetColorStyle
121
121
  }
122
122
  }
123
123
 
124
- type LoadingButtonStyleProps = {
124
+ type LoadingButtonStyleProps = PropsWithChildren<{
125
125
  variant: string;
126
126
  shape: string;
127
- children: React.ReactNode;
128
127
  color: string;
129
128
  loading: boolean;
130
129
  loadingPosition: string;
131
130
  theme: Theme;
132
- };
131
+ }>;
133
132
 
134
133
  const LoadingButtonStyle = styled(MuiLoadingButton, {
135
134
  shouldForwardProp: (prop) => prop !== 'shape' && prop !== 'variant'
@@ -207,14 +206,13 @@ const LoadingButtonStyle = styled(MuiLoadingButton, {
207
206
  }
208
207
  }));
209
208
 
210
- type LoadingButtonProps = {
209
+ type LoadingButtonProps = PropsWithChildren<{
211
210
  variant?: 'text' | 'outlined' | 'contained';
212
211
  shape: string;
213
- children: React.ReactNode;
214
212
  loading: boolean;
215
213
  loadingPosition: 'center' | 'start' | 'end';
216
214
  color: 'inherit' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning' | undefined;
217
- };
215
+ }>;
218
216
 
219
217
  const LoadingButton = forwardRef(
220
218
  (
@@ -1,6 +1,7 @@
1
1
  import { getColors } from '@/themes/getColors';
2
2
  import { Box, Tooltip as MuiTooltip, tooltipClasses } from '@mui/material';
3
3
  import { styled, useTheme } from '@mui/material/styles';
4
+ import { PropsWithChildren } from 'react';
4
5
 
5
6
  type GetVariantStyleProps = {
6
7
  color: string;
@@ -37,12 +38,11 @@ function getVariantStyle({ color, theme, labelColor }: GetVariantStyleProps) {
37
38
  }
38
39
  }
39
40
 
40
- type TooltipStyleProps = {
41
+ type TooltipStyleProps = PropsWithChildren<{
41
42
  color: string;
42
43
  labelColor: string;
43
- children: React.ReactNode;
44
44
  title: string;
45
- };
45
+ }>;
46
46
 
47
47
  const TooltipStyle = styled(
48
48
  // @ts-ignore
@@ -54,12 +54,11 @@ const TooltipStyle = styled(
54
54
  ...(color && getVariantStyle({ color, theme, labelColor }))
55
55
  }));
56
56
 
57
- type TooltipProps = {
58
- children: React.ReactNode;
57
+ type TooltipProps = PropsWithChildren<{
59
58
  arrow: boolean;
60
59
  labelColor?: string;
61
60
  rest: any;
62
- };
61
+ }>;
63
62
 
64
63
  function Tooltip({ children, arrow, labelColor = '', ...rest }: TooltipProps) {
65
64
  const theme = useTheme();
@@ -1,12 +1,11 @@
1
1
  import { Box, Collapse, Fade, Grow, Slide, Zoom } from '@mui/material';
2
- import { forwardRef } from 'react';
2
+ import { PropsWithChildren, forwardRef } from 'react';
3
3
 
4
- type TransitionsProps = {
5
- children: React.ReactNode;
4
+ type TransitionsProps = PropsWithChildren<{
6
5
  type?: 'grow' | 'fade' | 'collapse' | 'slide' | 'zoom';
7
6
  position?: 'top-left' | 'top-right' | 'top' | 'bottom-left' | 'bottom-right' | 'bottom';
8
7
  direction?: 'up' | 'down' | 'left' | 'right';
9
- };
8
+ }>;
10
9
 
11
10
  const Transitions = forwardRef(
12
11
  ({ children, position = 'top-left', type = 'grow', direction = 'up', ...others }: TransitionsProps, ref) => {
@@ -1,7 +1,7 @@
1
1
  import { MenuPopover } from '@/components/MenuPopover';
2
2
  import { MoreHoriz, MoreVert } from '@mui/icons-material';
3
3
  import { IconButton, MenuItem, styled } from '@mui/material';
4
- import React, { Children, useCallback, useState } from 'react';
4
+ import React, { Children, PropsWithChildren, useCallback, useState } from 'react';
5
5
 
6
6
  const BUTTON_STYLES = { width: '100%', justifyContent: 'flex-start' };
7
7
 
@@ -25,10 +25,7 @@ const StyledMenuPopover = styled(MenuPopover, {
25
25
  }
26
26
  }));
27
27
 
28
- type ActionsMenuProps = {
29
- children: React.ReactNode;
30
- horizontal?: boolean;
31
- };
28
+ type ActionsMenuProps = PropsWithChildren<{ horizontal?: boolean }>;
32
29
 
33
30
  /**
34
31
  * Allows you to draw a menu of actions grouped within a popover.
@@ -28,7 +28,11 @@ const initialState: AppState = {
28
28
 
29
29
  const AppStateContext = createContext<AppState>(initialState);
30
30
 
31
- function AppStateProvider({ children }: { children: React.ReactNode }) {
31
+ type AppStateProviderProps = {
32
+ children: React.ReactNode;
33
+ };
34
+
35
+ function AppStateProvider(props: AppStateProviderProps) {
32
36
  const [config, setConfig] = useState<AppState>(initialState);
33
37
  function openDialog(id: string, callback: () => void) {
34
38
  setConfig((config: AppState) => ({ ...config, openDialogs: [...config.openDialogs, id] }));
@@ -55,7 +59,7 @@ function AppStateProvider({ children }: { children: React.ReactNode }) {
55
59
  getCurrentDialog
56
60
  }}
57
61
  >
58
- {children}
62
+ {props.children}
59
63
  </AppStateContext.Provider>
60
64
  );
61
65
  }
@@ -1,11 +1,11 @@
1
1
  import { MainCard } from '@/components/MainCard';
2
2
  import { Box } from '@mui/material';
3
3
  import { useTheme } from '@mui/material/styles';
4
+ import { PropsWithChildren } from 'react';
4
5
 
5
- type AuthCardProps = {
6
- children: React.ReactNode;
7
- };
8
- function AuthCard({ children, ...other }: AuthCardProps) {
6
+ type AuthCardProps = PropsWithChildren;
7
+
8
+ function AuthCard({ children }: AuthCardProps) {
9
9
  const theme = useTheme();
10
10
  return (
11
11
  <MainCard
@@ -18,7 +18,6 @@ function AuthCard({ children, ...other }: AuthCardProps) {
18
18
  }
19
19
  }}
20
20
  content={false}
21
- {...other}
22
21
  border={false}
23
22
  boxShadow
24
23
  // @ts-ignore
@@ -3,16 +3,15 @@ import { AuthCard } from '@/components/AuthCard';
3
3
  import { Footer } from '@/components/Layout/Footer';
4
4
  import { MainIcon } from '@/components/MainIcon';
5
5
  import { Box, Grid } from '@mui/material';
6
- import React from 'react';
6
+ import React, { PropsWithChildren } from 'react';
7
7
 
8
- type AuthWrapperProps = {
8
+ type AuthWrapperProps = PropsWithChildren<{
9
9
  version: string;
10
10
  name: string;
11
11
  copy?: string;
12
12
  background?: React.ReactNode | React.ComponentType;
13
- children: React.ReactNode;
14
13
  logo?: React.ReactNode;
15
- };
14
+ }>;
16
15
 
17
16
  function AuthWrapper({ version, name, copy, children, logo, background = AuthBackground }: AuthWrapperProps) {
18
17
  return (
@@ -9,7 +9,7 @@ import {
9
9
  useResourceDefinitions,
10
10
  useTranslate
11
11
  } from 'ra-core';
12
- import { createContext, useContext, useEffect, useMemo, useState } from 'react';
12
+ import { PropsWithChildren, createContext, useContext, useEffect, useMemo, useState } from 'react';
13
13
  import { useLocation } from 'react-router';
14
14
 
15
15
  type MenuItem = {
@@ -252,13 +252,12 @@ const initialState: MenuProviderContextProps = {
252
252
  setMenu: notImplemented
253
253
  };
254
254
 
255
- type MenuProviderProps = {
255
+ type MenuProviderProps = PropsWithChildren<{
256
256
  menu: MenuItem[];
257
- children: React.ReactNode | React.ReactNode[];
258
- };
257
+ }>;
259
258
  const MenuContext = createContext<MenuProviderContextProps>(initialState);
260
259
 
261
- function MenuConfigProvider({ menu, children }: MenuProviderProps): JSX.Element {
260
+ function MenuConfigProvider({ menu, children }: MenuProviderProps) {
262
261
  const [menuConfig, setMenuConfig] = useState<MenuProviderContextProps>({ ...initialState, menu }) as any;
263
262
  function setMenu(menu: MenuItem[]) {
264
263
  setMenuConfig((menuConfig: MenuProviderContextProps) => ({ ...menuConfig, menu }));
@@ -1,11 +1,9 @@
1
1
  import { useLayoutDrawerState, useLayoutMediaState } from '@/components/Layout/Provider';
2
2
  import { useSx } from '@/hooks';
3
3
  import { Box, SxProps } from '@mui/material';
4
+ import { PropsWithChildren } from 'react';
4
5
 
5
- type NavListProps = {
6
- sx?: SxProps;
7
- children: React.ReactNode;
8
- };
6
+ type NavListProps = PropsWithChildren<{ sx?: SxProps }>;
9
7
 
10
8
  function NavList(props: NavListProps): JSX.Element {
11
9
  const { horizontal } = useLayoutMediaState();
@@ -1,5 +1,5 @@
1
1
  import { useLocalStorage } from '@/hooks';
2
- import { createContext, useContext } from 'react';
2
+ import { PropsWithChildren, createContext, useContext } from 'react';
3
3
 
4
4
  type ThemeMode = 'light' | 'dark';
5
5
  type ThemeOrientation = 'vertical' | 'horizontal';
@@ -50,10 +50,8 @@ type ThemeConfig = {
50
50
  isHorizontalLayout: (layout: ThemeDirection) => boolean;
51
51
  };
52
52
 
53
- type ThemeProvierProps = {
54
- children: React.ReactNode;
55
- initialConfig: ThemeConfig;
56
- };
53
+ type ThemeProvierProps = PropsWithChildren<{ initialConfig: ThemeConfig }>;
54
+
57
55
  function notImplemented(): void {
58
56
  throw new Error('Method must be implemented');
59
57
  }
@@ -2,15 +2,14 @@ import { StyledArrow } from './styles';
2
2
  import { getPosition } from '@/components/MenuPopover/getPosition';
3
3
  import { Arrow } from '@/components/MenuPopover/types';
4
4
  import { Popover } from '@mui/material';
5
- import React from 'react';
5
+ import { PropsWithChildren } from 'react';
6
6
 
7
- type MenuPopoverProps = {
7
+ type MenuPopoverProps = PropsWithChildren<{
8
8
  open: HTMLElement;
9
- children: React.ReactNode;
10
9
  arrow?: Arrow;
11
10
  disabledArrow?: boolean;
12
11
  sx?: object;
13
- };
12
+ }>;
14
13
 
15
14
  function MenuPopover({ open, children, arrow = 'top-right', disabledArrow, sx, ...other }: MenuPopoverProps) {
16
15
  const { style, anchorOrigin, transformOrigin } = getPosition(arrow);
@@ -4,7 +4,7 @@ import ContentAdd from '@mui/icons-material/Add';
4
4
  import { Dialog, Fab, useMediaQuery } from '@mui/material';
5
5
  import { SxProps, Theme, styled } from '@mui/material/styles';
6
6
  import clsx from 'clsx';
7
- import React, { useCallback, useState } from 'react';
7
+ import React, { Children, PropsWithChildren, useCallback, useState } from 'react';
8
8
  import {
9
9
  Button,
10
10
  CreateButtonClasses,
@@ -110,6 +110,7 @@ function CreateInDialogContent({
110
110
  onError,
111
111
  ...props
112
112
  }: CreateInDialogContentProps) {
113
+ const Child = Children.only(children);
113
114
  const queryClient = useQueryClient();
114
115
  const resource = useResourceContext();
115
116
  const redirect = useRedirect();
@@ -173,22 +174,24 @@ function CreateInDialogContent({
173
174
  } as CreateControllerResult
174
175
  }
175
176
  >
176
- {React.cloneElement(children, {
177
- ...children.props,
178
- modal: true,
179
- toolbar: (
180
- <Toolbar>
181
- <Button
182
- variant="text"
183
- size="medium"
184
- label="ra.action.cancel"
185
- onClick={onClose}
186
- disabled={createProps?.saving}
187
- />
188
- <SaveButton type="button" disabled={createProps?.saving} />
189
- </Toolbar>
190
- )
191
- })}
177
+ {React.isValidElement(Child)
178
+ ? React.cloneElement(Child, {
179
+ ...Child.props,
180
+ modal: true,
181
+ toolbar: (
182
+ <Toolbar>
183
+ <Button
184
+ variant="text"
185
+ size="medium"
186
+ label="ra.action.cancel"
187
+ onClick={onClose}
188
+ disabled={createProps?.saving}
189
+ />
190
+ <SaveButton type="button" disabled={createProps?.saving} />
191
+ </Toolbar>
192
+ )
193
+ })
194
+ : null}
192
195
  </CreateContextProvider>
193
196
  );
194
197
  }
@@ -211,55 +214,55 @@ const StyledFab = styled(Fab, { overridesResolver: (_props, styles) => styles.ro
211
214
  }
212
215
  }));
213
216
 
214
- type CreateInDialogButtonProps = CreateControllerProps & {
215
- fullWidth?: boolean;
216
- maxWidth?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | false;
217
- label?: string;
218
- record?: any;
219
- redirect?: RedirectionSideEffect;
220
- scrollToTop?: boolean;
221
- className?: string;
222
- sx?: SxProps;
223
- style?: React.CSSProperties;
224
- children: React.ReactElement;
225
- /**
226
- * If set to false, the button will always render as a regular button, regardless of the screen size.
227
- */
228
- fab: boolean;
229
- /**
230
- * @deprecated Use mutationOptions.onSubmit instead
231
- */
232
- onSubmit?: (record: any, close: () => void) => void;
233
- /**
234
- * @deprecated Use mutationOptions.onSuccess instead
235
- */
236
- onSuccess?: (data: any) => void;
237
- /**
238
- *
239
- * @deprecated Use mutationOptions.onError instead
240
- */
241
- onError?: (error: any) => void;
242
- };
217
+ type CreateInDialogButtonProps = CreateControllerProps &
218
+ PropsWithChildren<{
219
+ fullWidth?: boolean;
220
+ maxWidth?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | false;
221
+ label?: string;
222
+ record?: any;
223
+ redirect?: RedirectionSideEffect;
224
+ scrollToTop?: boolean;
225
+ className?: string;
226
+ sx?: SxProps;
227
+ style?: React.CSSProperties;
228
+ /**
229
+ * If set to false, the button will always render as a regular button, regardless of the screen size.
230
+ */
231
+ fab: boolean;
232
+ /**
233
+ * @deprecated Use mutationOptions.onSubmit instead
234
+ */
235
+ onSubmit?: (record: any, close: () => void) => void;
236
+ /**
237
+ * @deprecated Use mutationOptions.onSuccess instead
238
+ */
239
+ onSuccess?: (data: any) => void;
240
+ /**
241
+ *
242
+ * @deprecated Use mutationOptions.onError instead
243
+ */
244
+ onError?: (error: any) => void;
245
+ }>;
243
246
 
244
- type CreateInDialogContentProps = CreateControllerProps & {
245
- onClose: () => void;
246
- record?: any;
247
- redirect: RedirectionSideEffect | boolean | undefined;
248
- children: React.ReactElement;
249
- /**
250
- * You can use it to handle the form submission yourself.
251
- * Good luck with that.
252
- */
253
- onSubmit?: (record: any, close: () => void) => void;
254
- /**
255
- * @deprecated Use mutationOptions.onSuccess instead
256
- */
257
- onSuccess?: (data: any, close: () => void) => void;
258
- /**
259
- * @deprecated Use mutationOptions.onError instead
260
- */
261
- onError?: (error: any) => void;
262
- };
247
+ type CreateInDialogContentProps = CreateControllerProps &
248
+ PropsWithChildren<{
249
+ onClose: () => void;
250
+ record?: any;
251
+ redirect: RedirectionSideEffect | boolean | undefined;
252
+ /**
253
+ * You can use it to handle the form submission yourself.
254
+ * Good luck with that.
255
+ */
256
+ onSubmit?: (record: any, close: () => void) => void;
257
+ /**
258
+ * @deprecated Use mutationOptions.onSuccess instead
259
+ */
260
+ onSuccess?: (data: any, close: () => void) => void;
261
+ /**
262
+ * @deprecated Use mutationOptions.onError instead
263
+ */
264
+ onError?: (error: any) => void;
265
+ }>;
263
266
 
264
267
  export { CreateInDialogButton };
265
268
  export type { CreateInDialogButtonProps };
@@ -2,7 +2,7 @@ import { useAppConfig } from '@/components/AppStateProvider';
2
2
  import { Toolbar } from '@/components/ra-forms';
3
3
  import { Edit } from '@mui/icons-material';
4
4
  import { Breakpoint, Dialog } from '@mui/material';
5
- import React, { useCallback, useState } from 'react';
5
+ import React, { Children, PropsWithChildren, useCallback, useState } from 'react';
6
6
  import {
7
7
  Button,
8
8
  EditContextProvider,
@@ -15,11 +15,12 @@ import {
15
15
  useResourceContext
16
16
  } from 'react-admin';
17
17
 
18
- type EditInDialogContentProps = EditControllerProps & {
19
- onClose: () => void;
20
- children: React.ReactElement;
21
- };
18
+ type EditInDialogContentProps = EditControllerProps &
19
+ PropsWithChildren<{
20
+ onClose: () => void;
21
+ }>;
22
22
  function EditInDialogContent({ onClose, children, mutationMode = 'pessimistic', ...props }: EditInDialogContentProps) {
23
+ const Child = Children.only(children);
23
24
  const notify = useNotify();
24
25
  const record = useRecordContext();
25
26
  const resource = useResourceContext();
@@ -63,16 +64,18 @@ function EditInDialogContent({ onClose, children, mutationMode = 'pessimistic',
63
64
  saving: saving
64
65
  }}
65
66
  >
66
- {React.cloneElement(children, {
67
- ...children.props,
68
- modal: true,
69
- toolbar: (
70
- <Toolbar>
71
- <Button variant="text" size="medium" label="ra.action.cancel" onClick={onClose} />
72
- <SaveButton type="button" />
73
- </Toolbar>
74
- )
75
- })}
67
+ {React.isValidElement(Child)
68
+ ? React.cloneElement(Child, {
69
+ ...Child.props,
70
+ modal: true,
71
+ toolbar: (
72
+ <Toolbar>
73
+ <Button variant="text" size="medium" label="ra.action.cancel" onClick={onClose} />
74
+ <SaveButton type="button" />
75
+ </Toolbar>
76
+ )
77
+ })
78
+ : null}
76
79
  </EditContextProvider>
77
80
  );
78
81
  }
@@ -104,13 +107,13 @@ function EditInDialogButton({
104
107
  );
105
108
  }
106
109
 
107
- type EditInDialogButtonProps = EditControllerProps & {
108
- fullWidth?: boolean;
109
- maxWidth?: false | Breakpoint | undefined;
110
- label?: string;
111
- children: React.ReactElement;
112
- style?: React.CSSProperties;
113
- };
110
+ type EditInDialogButtonProps = EditControllerProps &
111
+ PropsWithChildren<{
112
+ fullWidth?: boolean;
113
+ maxWidth?: false | Breakpoint | undefined;
114
+ label?: string;
115
+ style?: React.CSSProperties;
116
+ }>;
114
117
 
115
118
  export { EditInDialogButton };
116
119
  export type { EditInDialogButtonProps };