@applica-software-guru/react-admin 1.5.313 → 1.5.314

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
@@ -107,5 +107,5 @@
107
107
  "type": "module",
108
108
  "types": "dist/index.d.ts",
109
109
  "typings": "dist/index.d.ts",
110
- "version": "1.5.313"
110
+ "version": "1.5.314"
111
111
  }
@@ -645,7 +645,7 @@
645
645
  "id": "en.ra.message.bulk_delete_content",
646
646
  "code": "ra.message.bulk_delete_content",
647
647
  "lang": "en",
648
- "text": "Sei sicuro di voler cancellare questo %{name}? |||| Sei sicuro di voler eliminare questi %{smart_count}?"
648
+ "text": "Sei sicuro di voler cancellare questo %{name}? |||| Sei sicuro di voler eliminare questi %{smart_count} %{name}?"
649
649
  },
650
650
  {
651
651
  "id": "en.ra.message.bulk_delete_title",
@@ -3,7 +3,7 @@ import { ReactElement } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import ActionDelete from '@mui/icons-material/Delete';
5
5
  import inflection from 'inflection';
6
- import { alpha, styled } from '@mui/material/styles';
6
+ import { SxProps, alpha, styled, useTheme } from '@mui/material/styles';
7
7
  import {
8
8
  DeleteManyParams,
9
9
  MutationMode,
@@ -19,6 +19,8 @@ import {
19
19
  import { BulkActionProps, Button, ButtonProps, Confirm } from 'react-admin';
20
20
  import { UseMutationOptions } from 'react-query';
21
21
  import _ from 'lodash';
22
+ import { Box, Typography } from '@mui/material';
23
+ import { DeleteFilled } from '@ant-design/icons';
22
24
 
23
25
  /**
24
26
  * BulkDeleteWithConfirmButton component allows you to delete multiple records with a confirmation dialog.
@@ -39,9 +41,10 @@ import _ from 'lodash';
39
41
  */
40
42
  function BulkDeleteWithConfirmButton(props: BulkDeleteWithConfirmButtonProps) {
41
43
  const {
42
- confirmTitle = 'ra.message.bulk_delete_title',
43
- confirmContent = 'ra.message.bulk_delete_content',
44
+ confirmTitle,
45
+ confirmContent,
44
46
  confirmColor = 'primary',
47
+ dialogSx,
45
48
  icon = defaultIcon,
46
49
  label = 'ra.action.delete',
47
50
  mutationMode = 'pessimistic',
@@ -58,6 +61,7 @@ function BulkDeleteWithConfirmButton(props: BulkDeleteWithConfirmButtonProps) {
58
61
  const resource = useResourceContext(props);
59
62
  const refresh = useRefresh();
60
63
  const translate = useTranslate();
64
+ const theme = useTheme();
61
65
  const [deleteMany, { isLoading }] = useDeleteMany(
62
66
  resource,
63
67
  { ids: selectedIds, meta: mutationMeta },
@@ -119,8 +123,86 @@ function BulkDeleteWithConfirmButton(props: BulkDeleteWithConfirmButtonProps) {
119
123
  <Confirm
120
124
  isOpen={isOpen}
121
125
  loading={isLoading}
122
- title={confirmTitle}
123
- content={confirmContent}
126
+ sx={
127
+ dialogSx || {
128
+ '& .MuiPaper-root': {
129
+ p: 2
130
+ },
131
+ '& .MuiDialogActions-root': {
132
+ display: 'flex',
133
+ justifyContent: 'space-between',
134
+ width: '100%',
135
+ '& .RaConfirm-confirmPrimary': {
136
+ backgroundColor: theme.palette.primary.main,
137
+ color: theme.palette.primary.contrastText,
138
+ ml: 2,
139
+ '&:hover': {
140
+ backgroundColor: theme.palette.primary.dark
141
+ }
142
+ },
143
+ '& .MuiButtonBase-root': {
144
+ width: '50%',
145
+ border: `1px solid ${theme.palette.action.disabled}`
146
+ },
147
+ '& .MuiButton-icon': {
148
+ display: 'none'
149
+ }
150
+ }
151
+ }
152
+ }
153
+ title={
154
+ confirmTitle ? (
155
+ typeof confirmTitle === 'string' ? (
156
+ translate(confirmTitle)
157
+ ) : (
158
+ confirmTitle
159
+ )
160
+ ) : (
161
+ <Box
162
+ sx={{
163
+ display: 'flex',
164
+ alignItems: 'center',
165
+ justifyContent: 'center'
166
+ }}
167
+ >
168
+ <Box
169
+ sx={{
170
+ color: 'primary.main',
171
+ fontSize: '28px',
172
+ borderRadius: '50%',
173
+ backgroundColor: 'primary.lighter',
174
+ width: '56px',
175
+ height: '56px',
176
+ display: 'flex',
177
+ alignItems: 'center',
178
+ justifyContent: 'center'
179
+ }}
180
+ >
181
+ <DeleteFilled />
182
+ </Box>
183
+ </Box>
184
+ )
185
+ }
186
+ content={
187
+ confirmContent || (
188
+ <Typography maxWidth="300px" variant="h4" align="center">
189
+ {translate('ra.message.bulk_delete_content', {
190
+ _: 'ra.message.bulk_delete_content',
191
+ smart_count: selectedIds.length,
192
+ name: translate(`resources.${resource}.forcedCaseName`, {
193
+ smart_count: selectedIds.length,
194
+ _: inflection.humanize(
195
+ translate(`resources.${resource}.name`, {
196
+ smart_count: selectedIds.length,
197
+ _: inflection.inflect(resource, selectedIds.length)
198
+ }),
199
+ true
200
+ )
201
+ })
202
+ })}
203
+ </Typography>
204
+ )
205
+ }
124
206
  confirmColor={confirmColor}
125
207
  translateOptions={{
126
208
  smart_count: selectedIds.length,
@@ -158,6 +240,7 @@ interface BulkDeleteWithConfirmButtonProps<RecordType extends RaRecord = any, Mu
158
240
  confirmContent?: React.ReactNode;
159
241
  confirmTitle?: React.ReactNode;
160
242
  confirmColor?: 'primary' | 'warning';
243
+ dialogSx?: SxProps;
161
244
  icon?: ReactElement;
162
245
  mutationMode: MutationMode;
163
246
  mutationOptions?: UseMutationOptions<RecordType, MutationOptionsError, DeleteManyParams<RecordType>> & {
@@ -197,6 +280,7 @@ BulkDeleteWithConfirmButton.propTypes = {
197
280
  confirmTitle: PropTypes.node,
198
281
  confirmContent: PropTypes.node,
199
282
  confirmColor: PropTypes.string,
283
+ dialogSx: PropTypes.object,
200
284
  icon: PropTypes.element,
201
285
  label: PropTypes.string,
202
286
  mutationMode: PropTypes.oneOf(['pessimistic', 'optimistic', 'undoable']),
@@ -23,7 +23,7 @@ function DeleteWithConfirmButton<RecordType extends RaRecord = any>(
23
23
  confirmColor = 'primary',
24
24
  color = 'error',
25
25
  dialogSx,
26
- icon = defaultIcon,
26
+ icon = <ActionDelete />,
27
27
  label = 'ra.action.delete',
28
28
  mutationMode = 'pessimistic',
29
29
  mutationOptions,
@@ -122,15 +122,22 @@ function DeleteWithConfirmButton<RecordType extends RaRecord = any>(
122
122
  )
123
123
  }
124
124
  content={
125
- confirmContent ? (
126
- typeof confirmContent === 'string' ? (
127
- translate(confirmContent)
128
- ) : (
129
- confirmContent
130
- )
131
- ) : (
125
+ confirmContent || (
132
126
  <Typography maxWidth="300px" variant="h4" align="center">
133
- {translate('ra.message.delete_content')}
127
+ {translate('ra.message.delete_content', {
128
+ _: 'ra.message.delete_content',
129
+ name: translate(`resources.${resource}.forcedCaseName`, {
130
+ smart_count: 1,
131
+ _: inflection.humanize(
132
+ translate(`resources.${resource}.name`, {
133
+ smart_count: 1,
134
+ _: inflection.singularize(resource)
135
+ }),
136
+ true
137
+ )
138
+ }),
139
+ id: record?.id
140
+ })}
134
141
  </Typography>
135
142
  )
136
143
  }
@@ -172,6 +179,4 @@ DeleteWithConfirmButton.propTypes = {
172
179
  translateOptions: PropTypes.object
173
180
  };
174
181
 
175
- const defaultIcon = <ActionDelete />;
176
-
177
182
  export { DeleteWithConfirmButton };