@applica-software-guru/react-admin 1.5.236 → 1.5.238

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
@@ -115,5 +115,5 @@
115
115
  "type": "module",
116
116
  "types": "dist/index.d.ts",
117
117
  "typings": "dist/index.d.ts",
118
- "version": "1.5.236"
118
+ "version": "1.5.238"
119
119
  }
@@ -1,7 +1,7 @@
1
1
  import { Toolbar } from '@/components/ra-forms';
2
- import { Breakpoint, Dialog } from '@mui/material';
3
- import { CreateBase, UseCreateMutateParams, useResourceContext } from 'ra-core';
4
- import { Button, CreateButton, CreateButtonProps, CreateProps, SaveButton } from 'ra-ui-materialui';
2
+ import { Breakpoint, Button, Dialog } from '@mui/material';
3
+ import { CreateBase, UseCreateMutateParams, useResourceContext, useTranslate } from 'ra-core';
4
+ import { CreateButton, CreateButtonProps, CreateProps, SaveButton } from 'ra-ui-materialui';
5
5
  import React, { Children, PropsWithChildren, useCallback, useState } from 'react';
6
6
  import { FieldValues, useFormContext } from 'react-hook-form';
7
7
  import { useQueryClient } from 'react-query';
@@ -51,6 +51,7 @@ type SubmitButtonProps = {
51
51
  function SubmitButton(props: SubmitButtonProps) {
52
52
  const { onSubmit, closeDialog } = props;
53
53
  const { handleSubmit } = useFormContext();
54
+ const translate = useTranslate();
54
55
  const handleClick = useCallback(
55
56
  (event: any) => {
56
57
  (event as Event).preventDefault();
@@ -59,7 +60,11 @@ function SubmitButton(props: SubmitButtonProps) {
59
60
  },
60
61
  [handleSubmit, onSubmit, closeDialog]
61
62
  );
62
- return <Button onClick={handleClick} label="ra.action.save" color="primary" variant="contained" size="medium" />;
63
+ return (
64
+ <Button onClick={handleClick} color="primary" variant="contained" size="medium">
65
+ {translate('ra.action.save')}
66
+ </Button>
67
+ );
63
68
  }
64
69
  type CreateInDialogButtonProps = PropsWithChildren &
65
70
  CreateProps &
@@ -67,7 +72,7 @@ type CreateInDialogButtonProps = PropsWithChildren &
67
72
  maxWidth: Breakpoint;
68
73
  fullWidth?: boolean;
69
74
  fullScreen?: boolean;
70
-
75
+ scroll: 'paper' | 'body' | undefined;
71
76
  /**
72
77
  * Custom handler for the submit event, in this case you are responsible for closing the dialog.
73
78
  * @example
@@ -86,9 +91,10 @@ type CreateInDialogButtonProps = PropsWithChildren &
86
91
  onSubmit?: SubmitFunction;
87
92
  };
88
93
  function CreateInDialogButton(props: CreateInDialogButtonProps) {
89
- const { children, maxWidth = 'md', fullWidth = true, fullScreen, onSubmit, mutationOptions, ...rest } = props;
94
+ const { children, maxWidth = 'md', fullWidth = true, fullScreen, onSubmit, mutationOptions, scroll, ...rest } = props;
90
95
  const queryClient = useQueryClient();
91
96
  const resource = useResourceContext();
97
+ const translate = useTranslate();
92
98
  const Child = Children.only(children);
93
99
  const [open, setOpen] = useState(false);
94
100
  const handleOpen = useCallback(() => setOpen(true), []);
@@ -124,14 +130,28 @@ function CreateInDialogButton(props: CreateInDialogButtonProps) {
124
130
  onSuccess: handleSuccess
125
131
  }}
126
132
  >
127
- <Dialog open={open} onClose={handleClose} maxWidth={maxWidth} fullWidth={fullWidth} fullScreen={fullScreen}>
133
+ <Dialog
134
+ open={open}
135
+ scroll={scroll}
136
+ onClose={handleClose}
137
+ maxWidth={maxWidth}
138
+ fullWidth={fullWidth}
139
+ fullScreen={fullScreen}
140
+ sx={{
141
+ '& .MuiToolbar-root': {
142
+ position: 'relative !important'
143
+ }
144
+ }}
145
+ >
128
146
  {React.isValidElement(Child)
129
147
  ? React.cloneElement(Child, {
130
148
  ...Child.props,
131
149
  modal: true,
132
150
  toolbar: (
133
151
  <Toolbar>
134
- <Button variant="text" size="medium" label="ra.action.cancel" onClick={handleClose} />
152
+ <Button variant="text" size="medium" onClick={handleClose}>
153
+ {translate('ra.action.cancel')}
154
+ </Button>
135
155
  {onSubmit ? (
136
156
  <SubmitButton onSubmit={onSubmit!} closeDialog={handleClose} />
137
157
  ) : (
@@ -1,7 +1,7 @@
1
1
  import { Toolbar } from '@/components/ra-forms';
2
- import { Breakpoint, Dialog } from '@mui/material';
3
- import { EditBase, UseUpdateMutateParams, useRecordContext } from 'ra-core';
4
- import { Button, EditButton, EditProps, SaveButton } from 'ra-ui-materialui';
2
+ import { Breakpoint, Button, Dialog } from '@mui/material';
3
+ import { EditBase, UseUpdateMutateParams, useRecordContext, useTranslate } from 'ra-core';
4
+ import { EditButton, EditProps, SaveButton } from 'ra-ui-materialui';
5
5
  import React, { Children, PropsWithChildren, useCallback, useState } from 'react';
6
6
 
7
7
  type ResponsiveButtonProps = {
@@ -27,9 +27,10 @@ type EditInDialogButtonProps = PropsWithChildren &
27
27
  maxWidth: Breakpoint;
28
28
  fullWidth?: boolean;
29
29
  fullScreen?: boolean;
30
+ scroll: 'paper' | 'body' | undefined;
30
31
  };
31
32
  function EditInDialogButton(props: EditInDialogButtonProps): JSX.Element {
32
- const { children, maxWidth = 'md', fullWidth = true, fullScreen, mutationOptions, ...rest } = props;
33
+ const { children, maxWidth = 'md', fullWidth = true, fullScreen, mutationOptions, scroll, ...rest } = props;
33
34
  const [open, setOpen] = useState(false);
34
35
  const Child = Children.only(children);
35
36
  const handleOpen = useCallback(() => setOpen(true), []);
@@ -42,6 +43,7 @@ function EditInDialogButton(props: EditInDialogButtonProps): JSX.Element {
42
43
  [handleClose, props.mutationOptions]
43
44
  );
44
45
  const record = useRecordContext();
46
+ const translate = useTranslate();
45
47
  return (
46
48
  <>
47
49
  <ResponsiveButton {...rest} onClick={handleOpen} />
@@ -56,11 +58,17 @@ function EditInDialogButton(props: EditInDialogButtonProps): JSX.Element {
56
58
  >
57
59
  <Dialog
58
60
  open={open}
61
+ scroll={scroll}
59
62
  onClose={handleClose}
60
63
  fullWidth={fullWidth}
61
64
  maxWidth={maxWidth}
62
65
  fullScreen={fullScreen}
63
66
  keepMounted={false}
67
+ sx={{
68
+ '& .MuiToolbar-root': {
69
+ position: 'relative !important'
70
+ }
71
+ }}
64
72
  >
65
73
  {React.isValidElement(Child)
66
74
  ? React.cloneElement(Child, {
@@ -68,7 +76,9 @@ function EditInDialogButton(props: EditInDialogButtonProps): JSX.Element {
68
76
  modal: true,
69
77
  toolbar: (
70
78
  <Toolbar>
71
- <Button variant="text" size="medium" label="ra.action.cancel" onClick={handleClose} />
79
+ <Button variant="text" size="medium" onClick={handleClose}>
80
+ {translate('ra.action.cancel')}
81
+ </Button>
72
82
  <SaveButton type="button" />
73
83
  </Toolbar>
74
84
  )
@@ -16,7 +16,7 @@ import {
16
16
 
17
17
  function CategoryAddButton() {
18
18
  return (
19
- <CreateInDialogButton maxWidth="sm" redirect="list" size="small" variant="text">
19
+ <CreateInDialogButton maxWidth="sm" redirect="list" size="medium" variant="text">
20
20
  <CategoryForm />
21
21
  </CreateInDialogButton>
22
22
  );
@@ -41,15 +41,15 @@ function RolesInput({ record, source, roles, ...props }) {
41
41
  );
42
42
  }
43
43
 
44
- function ImageField({ record }) {
44
+ function ImageField(record) {
45
45
  return <CoverField source="image" record={record} width={50} height={50} circle />;
46
46
  }
47
47
 
48
- function NameField({ record }) {
48
+ function NameField(record) {
49
49
  return record.name;
50
50
  }
51
51
 
52
- function SecondaryField({ record }) {
52
+ function SecondaryField(record) {
53
53
  return record.email;
54
54
  }
55
55