@dashadmin/dash-components 1.3.24 → 1.3.26
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/dist/components/AuditLog/AuditLog.js +345 -1
- package/dist/components/AuditLog/index.js +4 -1
- package/dist/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.js +630 -3
- package/dist/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.js +53 -1
- package/dist/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.js +647 -3
- package/dist/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.js +53 -1
- package/dist/components/Json/Json.js +235 -1
- package/dist/components/JsonColorSelector/JsonColorSelector.js +1172 -1
- package/dist/components/JsonColorSelector/JsonColorSelectorEnhanced.js +863 -2
- package/dist/components/JsonColorSelector/JsonCssVarValues.js +738 -1
- package/dist/components/JsonColorSelector/components/ColorEditDialog.js +426 -1
- package/dist/components/JsonColorSelector/components/ColorPaletteItem.js +75 -1
- package/dist/components/JsonColorSelector/components/ImageColorExtractor.js +283 -1
- package/dist/components/JsonColorSelector/helpers/functions.js +101 -1
- package/dist/components/JsonColorSelector/useAsyncColorThief.js +105 -1
- package/dist/components/ListActive/ListActive.js +126 -1
- package/dist/components/ListActive/ListBoolean.js +124 -1
- package/dist/components/NotificationPreferences/NotificationPreferences.js +317 -1
- package/dist/components/NotificationPreferences/index.js +7 -1
- package/dist/components/SearchableSelects/RASearchableSelect.js +236 -1
- package/dist/components/SearchableSelects/RASearchableSelectCheckboxes.js +479 -1
- package/dist/components/SearchableSelects/RASearchableSelectChips.js +465 -1
- package/dist/components/SearchableSelects/RASearchableSelectChipsRecordContext.js +295 -1
- package/dist/components/SearchableSelects/SearchableSelect.js +202 -1
- package/dist/components/SearchableSelects/SearchableSelectCheckboxes.js +290 -1
- package/dist/components/SortableDataGrid/SortableDataGrid.js +72 -1
- package/dist/components/SortableDataGrid/SortableDataGridBody.js +167 -1
- package/dist/components/SortableDataGrid/SortableDataGridHeader.js +109 -1
- package/dist/components/SortableDataGrid/SortableDataGridRow.js +283 -1
- package/dist/components/Upload/SingleImageUploader.js +40 -1
- package/dist/components/custom/PackageCopyMethod.js +78 -1
- package/dist/components/custom/PackageRadioButtonGroup.js +45 -1
- package/dist/components/dialog/Basic.js +8 -1
- package/dist/components/dialog/Correct.js +14 -1
- package/dist/components/dialog/Error.js +14 -1
- package/dist/components/dialog/Info.js +14 -1
- package/dist/components/dialog/InfoV2.js +21 -1
- package/dist/components/dialog/NotFound.js +14 -1
- package/dist/components/dialog/QuickSearch.js +117 -1
- package/dist/components/notifications/NotificationsCenter.js +597 -1
- package/dist/components/notifications/index.js +24 -1
- package/dist/components/tables/PaginationComponent.js +36 -1
- package/dist/components/theme/AppLoadingFallback.js +38 -2
- package/dist/components/theme/ErrorBoundary.js +52 -1
- package/dist/components/theme/InitialLoader.js +13 -1
- package/dist/components/theme/NotFound.js +136 -1
- package/dist/components/theme/NotResults.js +38 -1
- package/dist/hooks/useDraggable.js +6 -1
- package/dist/hooks/useNotifications.js +8 -1
- package/dist/hooks/useQuickSearch.js +26 -1
- package/dist/index.js +66 -5567
- package/dist/utils/setNativeValue.js +17 -1
- package/package.json +149 -132
- package/src/components/AuditLog/AuditLog.tsx +476 -0
- package/src/components/AuditLog/index.ts +2 -0
- package/src/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.tsx +917 -0
- package/src/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.tsx +39 -0
- package/src/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.tsx +916 -0
- package/src/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.tsx +44 -0
- package/src/components/Json/Json.tsx +312 -0
- package/src/components/JsonColorSelector/JsonColorSelector.tsx +1435 -0
- package/src/components/JsonColorSelector/JsonColorSelectorEnhanced.tsx +1029 -0
- package/src/components/JsonColorSelector/JsonCssVarValues.tsx +863 -0
- package/src/components/JsonColorSelector/components/ColorEditDialog.tsx +491 -0
- package/src/components/JsonColorSelector/components/ColorPaletteItem.tsx +80 -0
- package/src/components/JsonColorSelector/components/ImageColorExtractor.tsx +328 -0
- package/src/components/JsonColorSelector/helpers/functions.tsx +123 -0
- package/src/components/JsonColorSelector/interfaces/interfaces.tsx +22 -0
- package/src/components/JsonColorSelector/useAsyncColorThief.tsx +97 -0
- package/src/components/ListActive/ListActive.tsx +106 -0
- package/src/components/ListActive/ListBoolean.tsx +96 -0
- package/src/components/NotificationPreferences/NotificationPreferences.tsx +463 -0
- package/src/components/NotificationPreferences/index.tsx +2 -0
- package/src/components/SearchableSelects/RASearchableSelect.tsx +300 -0
- package/src/components/SearchableSelects/RASearchableSelectCheckboxes.tsx +604 -0
- package/src/components/SearchableSelects/RASearchableSelectChips.tsx +558 -0
- package/src/components/SearchableSelects/RASearchableSelectChipsRecordContext.tsx +362 -0
- package/src/components/SearchableSelects/SearchableSelect.tsx +321 -0
- package/src/components/SearchableSelects/SearchableSelectCheckboxes.tsx +355 -0
- package/src/components/SortableDataGrid/SortableDataGrid.tsx +56 -0
- package/src/components/SortableDataGrid/SortableDataGridBody.tsx +175 -0
- package/src/components/SortableDataGrid/SortableDataGridHeader.tsx +171 -0
- package/src/components/SortableDataGrid/SortableDataGridRow.tsx +247 -0
- package/src/components/Upload/SingleImageUploader.tsx +55 -0
- package/src/components/custom/PackageCopyMethod.tsx +109 -0
- package/src/components/custom/PackageRadioButtonGroup.tsx +47 -0
- package/src/components/dialog/Basic.tsx +11 -0
- package/src/components/dialog/Correct.tsx +16 -0
- package/src/components/dialog/Error.tsx +15 -0
- package/src/components/dialog/Info.tsx +15 -0
- package/src/components/dialog/InfoV2.tsx +35 -0
- package/src/components/dialog/NotFound.tsx +18 -0
- package/src/components/dialog/QuickSearch.tsx +115 -0
- package/src/components/notifications/NotificationsCenter.tsx +792 -0
- package/src/components/notifications/index.ts +42 -0
- package/src/components/tables/PaginationComponent.tsx +17 -0
- package/src/components/theme/AppLoadingFallback.tsx +42 -0
- package/src/components/theme/ErrorBoundary.tsx +57 -0
- package/src/components/theme/InitialLoader.tsx +16 -0
- package/src/components/theme/NotFound.tsx +124 -0
- package/src/components/theme/NotResults.tsx +54 -0
- package/src/hooks/useDraggable.ts +11 -0
- package/src/hooks/useNotifications.ts +14 -0
- package/src/hooks/useQuickSearch.tsx +29 -0
- package/src/index.tsx +77 -0
- package/src/utils/setNativeValue.tsx +23 -0
- package/dist/color-thief-CTwGFhOB.js +0 -272
- /package/{dist → src}/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayAutoSearch.tsx.wip +0 -0
- /package/{dist → src}/components/JsonColorSelector/JsonColorSelector.tsx.bkup +0 -0
- /package/{dist → src}/components/SortableDataGrid/README.md +0 -0
- /package/{dist → src}/styles/index.less +0 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Children, isValidElement, useCallback } from 'react';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
useListContext,
|
|
6
|
+
useResourceContext,
|
|
7
|
+
/*
|
|
8
|
+
Identifier,
|
|
9
|
+
RaRecord,
|
|
10
|
+
SortPayload,
|
|
11
|
+
useTranslate,
|
|
12
|
+
*/
|
|
13
|
+
} from 'react-admin';
|
|
14
|
+
|
|
15
|
+
import { Checkbox, TableCell, TableHead, TableRow } from '@mui/material';
|
|
16
|
+
import clsx from 'clsx';
|
|
17
|
+
import {
|
|
18
|
+
DatagridClasses,
|
|
19
|
+
DatagridHeader,
|
|
20
|
+
DatagridHeaderCell,
|
|
21
|
+
DatagridHeaderProps,
|
|
22
|
+
useDatagridContext,
|
|
23
|
+
useTranslate,
|
|
24
|
+
} from 'react-admin';
|
|
25
|
+
import MenuIcon from '@mui/icons-material/Menu';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The default Datagrid Header component.
|
|
29
|
+
*
|
|
30
|
+
* Renders select all checkbox as well as column header buttons used for sorting.
|
|
31
|
+
*/
|
|
32
|
+
export interface SortableDatagridHeaderProps extends DatagridHeaderProps {
|
|
33
|
+
hasSort?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const SortableDatagridHeader = (props: SortableDatagridHeaderProps) => {
|
|
37
|
+
const {
|
|
38
|
+
children,
|
|
39
|
+
className,
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
41
|
+
hasExpand = false,
|
|
42
|
+
hasSort = true,
|
|
43
|
+
hasBulkActions = false,
|
|
44
|
+
isRowSelectable,
|
|
45
|
+
} = props;
|
|
46
|
+
|
|
47
|
+
{/* @ts-ignore */}
|
|
48
|
+
const resource = useResourceContext(props);
|
|
49
|
+
const translate = useTranslate();
|
|
50
|
+
{/* @ts-ignore */}
|
|
51
|
+
const { sort, data, onSelect, selectedIds, setSort } = useListContext(props);
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
53
|
+
const { expandSingle } = useDatagridContext();
|
|
54
|
+
|
|
55
|
+
const updateSortCallback = useCallback(
|
|
56
|
+
(event) => {
|
|
57
|
+
event.stopPropagation();
|
|
58
|
+
const newField = event.currentTarget.dataset.field;
|
|
59
|
+
const newOrder =
|
|
60
|
+
sort.field === newField
|
|
61
|
+
? sort.order && sort.order.toLocaleLowerCase() === 'asc'
|
|
62
|
+
? 'ASC'
|
|
63
|
+
: 'DESC'
|
|
64
|
+
: event.currentTarget.dataset.order;
|
|
65
|
+
|
|
66
|
+
setSort({ field: newField, order: newOrder });
|
|
67
|
+
},
|
|
68
|
+
[sort.field, sort.order, setSort],
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const updateSort = setSort ? updateSortCallback : null;
|
|
72
|
+
|
|
73
|
+
const handleSelectAll = useCallback(
|
|
74
|
+
(event) =>
|
|
75
|
+
onSelect(
|
|
76
|
+
event.target.checked
|
|
77
|
+
? selectedIds.concat(
|
|
78
|
+
data
|
|
79
|
+
.filter((record) => !selectedIds.includes(record.id))
|
|
80
|
+
.filter((record) =>
|
|
81
|
+
isRowSelectable ? isRowSelectable(record) : true,
|
|
82
|
+
)
|
|
83
|
+
.map((record) => record.id))
|
|
84
|
+
: [],
|
|
85
|
+
),
|
|
86
|
+
[data, onSelect, isRowSelectable, selectedIds],
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const selectableIds = Array.isArray(data)
|
|
90
|
+
? isRowSelectable
|
|
91
|
+
? data
|
|
92
|
+
.filter((record) => isRowSelectable(record))
|
|
93
|
+
.map((record) => record.id)
|
|
94
|
+
: data.map((record) => record.id)
|
|
95
|
+
: [];
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<TableHead className={clsx(className, DatagridClasses.thead)}>
|
|
99
|
+
<TableRow
|
|
100
|
+
className={clsx(DatagridClasses.row, DatagridClasses.headerRow)}
|
|
101
|
+
>
|
|
102
|
+
{hasSort && (
|
|
103
|
+
<TableCell
|
|
104
|
+
padding='none'
|
|
105
|
+
className={clsx(
|
|
106
|
+
DatagridClasses.headerCell,
|
|
107
|
+
DatagridClasses.expandHeader,
|
|
108
|
+
)}
|
|
109
|
+
>
|
|
110
|
+
<MenuIcon sx={{ cursor: 'pointer' }} className='handle' />
|
|
111
|
+
</TableCell>
|
|
112
|
+
)}
|
|
113
|
+
{/*hasExpand && (
|
|
114
|
+
<TableCell
|
|
115
|
+
padding="none"
|
|
116
|
+
className={clsx(
|
|
117
|
+
DatagridClasses.headerCell,
|
|
118
|
+
DatagridClasses.expandHeader
|
|
119
|
+
)}
|
|
120
|
+
>
|
|
121
|
+
{!expandSingle ? (
|
|
122
|
+
<ExpandAllButton
|
|
123
|
+
resource={resource}
|
|
124
|
+
ids={data.map(record => record.id)}
|
|
125
|
+
/>
|
|
126
|
+
) : null}
|
|
127
|
+
</TableCell>
|
|
128
|
+
)*/}
|
|
129
|
+
{hasBulkActions && selectedIds && (
|
|
130
|
+
<TableCell padding='checkbox' className={DatagridClasses.headerCell}>
|
|
131
|
+
<Checkbox
|
|
132
|
+
aria-label={translate('ra.action.select_all', {
|
|
133
|
+
_: 'Select all',
|
|
134
|
+
})}
|
|
135
|
+
className='select-all'
|
|
136
|
+
color='primary'
|
|
137
|
+
checked={
|
|
138
|
+
selectedIds.length > 0 &&
|
|
139
|
+
selectableIds.length > 0 &&
|
|
140
|
+
selectableIds.every((id) => selectedIds.includes(id))
|
|
141
|
+
}
|
|
142
|
+
onChange={handleSelectAll}
|
|
143
|
+
/>
|
|
144
|
+
</TableCell>
|
|
145
|
+
)}
|
|
146
|
+
{Children.map(children, (field, index) =>
|
|
147
|
+
isValidElement(field) ? (
|
|
148
|
+
<DatagridHeaderCell
|
|
149
|
+
className={clsx(
|
|
150
|
+
DatagridClasses.headerCell,
|
|
151
|
+
`column-${(field.props as any).source}`,
|
|
152
|
+
)}
|
|
153
|
+
sort={sort}
|
|
154
|
+
field={field}
|
|
155
|
+
isSorting={
|
|
156
|
+
sort.field ===
|
|
157
|
+
((field.props as any).sortBy || (field.props as any).source)
|
|
158
|
+
}
|
|
159
|
+
key={(field.props as any).source || index}
|
|
160
|
+
/* @ts-ignore */
|
|
161
|
+
resource={resource}
|
|
162
|
+
updateSort={updateSort}
|
|
163
|
+
/>
|
|
164
|
+
) : null,
|
|
165
|
+
)}
|
|
166
|
+
</TableRow>
|
|
167
|
+
</TableHead>
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
DatagridHeader.displayName = 'DatagridHeader';
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
isValidElement,
|
|
3
|
+
cloneElement,
|
|
4
|
+
createElement,
|
|
5
|
+
useState,
|
|
6
|
+
useEffect,
|
|
7
|
+
useCallback,
|
|
8
|
+
memo,
|
|
9
|
+
FC,
|
|
10
|
+
} from 'react';
|
|
11
|
+
import { isElement } from 'react-is';
|
|
12
|
+
import clsx from 'clsx';
|
|
13
|
+
import { TableCell, TableRow, Checkbox } from '@mui/material';
|
|
14
|
+
import {
|
|
15
|
+
RecordContextProvider,
|
|
16
|
+
shallowEqual,
|
|
17
|
+
useExpanded,
|
|
18
|
+
useResourceContext,
|
|
19
|
+
useTranslate,
|
|
20
|
+
useCreatePath,
|
|
21
|
+
useRecordContext,
|
|
22
|
+
} from 'react-admin';
|
|
23
|
+
import { useNavigate } from 'react-router-dom';
|
|
24
|
+
import {
|
|
25
|
+
DatagridCell,
|
|
26
|
+
DatagridClasses,
|
|
27
|
+
DatagridRow,
|
|
28
|
+
DatagridRowProps,
|
|
29
|
+
ExpandRowButton,
|
|
30
|
+
useDatagridContext,
|
|
31
|
+
} from 'react-admin';
|
|
32
|
+
import MenuIcon from '@mui/icons-material/Menu';
|
|
33
|
+
|
|
34
|
+
const computeNbColumns = (expand, children, hasBulkActions) =>
|
|
35
|
+
expand
|
|
36
|
+
? 1 + // show expand button
|
|
37
|
+
(hasBulkActions ? 1 : 0) + // checkbox column
|
|
38
|
+
React.Children.toArray(children).filter((child) => !!child).length // non-null children
|
|
39
|
+
: 0; // we don't need to compute columns if there is no expand panel;
|
|
40
|
+
|
|
41
|
+
const SortableDatagridRow: FC<DatagridRowProps> = React.forwardRef(
|
|
42
|
+
(props, ref) => {
|
|
43
|
+
const {
|
|
44
|
+
children,
|
|
45
|
+
className,
|
|
46
|
+
expand,
|
|
47
|
+
hasBulkActions = false,
|
|
48
|
+
hover = true,
|
|
49
|
+
id,
|
|
50
|
+
onToggleItem,
|
|
51
|
+
record: recordOverride,
|
|
52
|
+
rowClick,
|
|
53
|
+
selected = false,
|
|
54
|
+
style,
|
|
55
|
+
selectable = true,
|
|
56
|
+
...rest
|
|
57
|
+
} = props;
|
|
58
|
+
|
|
59
|
+
const context = useDatagridContext();
|
|
60
|
+
const translate = useTranslate();
|
|
61
|
+
const record = useRecordContext(props);
|
|
62
|
+
const expandable =
|
|
63
|
+
(!context ||
|
|
64
|
+
!context.isRowExpandable ||
|
|
65
|
+
context.isRowExpandable(record)) &&
|
|
66
|
+
expand;
|
|
67
|
+
const resource = useResourceContext(props);
|
|
68
|
+
const createPath = useCreatePath();
|
|
69
|
+
const [expanded, toggleExpanded] = useExpanded(
|
|
70
|
+
resource,
|
|
71
|
+
id,
|
|
72
|
+
context && context.expandSingle,
|
|
73
|
+
);
|
|
74
|
+
const [nbColumns, setNbColumns] = useState(() =>
|
|
75
|
+
computeNbColumns(expandable, children, hasBulkActions),
|
|
76
|
+
);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
// Fields can be hidden dynamically based on permissions;
|
|
79
|
+
// The expand panel must span over the remaining columns
|
|
80
|
+
// So we must recompute the number of columns to span on
|
|
81
|
+
const newNbColumns = computeNbColumns(
|
|
82
|
+
expandable,
|
|
83
|
+
children,
|
|
84
|
+
hasBulkActions,
|
|
85
|
+
);
|
|
86
|
+
if (newNbColumns !== nbColumns) {
|
|
87
|
+
setNbColumns(newNbColumns);
|
|
88
|
+
}
|
|
89
|
+
}, [expandable, nbColumns, children, hasBulkActions]);
|
|
90
|
+
|
|
91
|
+
const navigate = useNavigate();
|
|
92
|
+
|
|
93
|
+
const handleToggleExpand = useCallback(
|
|
94
|
+
(event) => {
|
|
95
|
+
toggleExpanded();
|
|
96
|
+
event.stopPropagation();
|
|
97
|
+
},
|
|
98
|
+
[toggleExpanded],
|
|
99
|
+
);
|
|
100
|
+
const handleToggleSelection = useCallback(
|
|
101
|
+
(event) => {
|
|
102
|
+
if (!selectable) return;
|
|
103
|
+
onToggleItem(id, event);
|
|
104
|
+
event.stopPropagation();
|
|
105
|
+
},
|
|
106
|
+
[id, onToggleItem, selectable],
|
|
107
|
+
);
|
|
108
|
+
const handleClick = useCallback(
|
|
109
|
+
async (event) => {
|
|
110
|
+
event.persist();
|
|
111
|
+
const type =
|
|
112
|
+
typeof rowClick === 'function'
|
|
113
|
+
? await rowClick(id, resource, record)
|
|
114
|
+
: rowClick;
|
|
115
|
+
if (type === false || type === null) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (['edit', 'show'].includes(type)) {
|
|
119
|
+
navigate(createPath({ resource, id, type }));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (type === 'expand') {
|
|
123
|
+
handleToggleExpand(event);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (type === 'toggleSelection') {
|
|
127
|
+
handleToggleSelection(event);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
navigate(type);
|
|
131
|
+
},
|
|
132
|
+
[
|
|
133
|
+
rowClick,
|
|
134
|
+
id,
|
|
135
|
+
resource,
|
|
136
|
+
record,
|
|
137
|
+
navigate,
|
|
138
|
+
createPath,
|
|
139
|
+
handleToggleExpand,
|
|
140
|
+
handleToggleSelection,
|
|
141
|
+
],
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<RecordContextProvider value={record}>
|
|
146
|
+
{/* @ts-ignore */}
|
|
147
|
+
<TableRow
|
|
148
|
+
ref={ref}
|
|
149
|
+
className={clsx(className, {
|
|
150
|
+
[DatagridClasses.expandable]: expandable,
|
|
151
|
+
[DatagridClasses.selectable]: selectable,
|
|
152
|
+
[DatagridClasses.clickableRow]:
|
|
153
|
+
typeof rowClick === 'function' ? true : rowClick,
|
|
154
|
+
})}
|
|
155
|
+
key={id}
|
|
156
|
+
style={style}
|
|
157
|
+
hover={hover}
|
|
158
|
+
onClick={handleClick}
|
|
159
|
+
{...rest}
|
|
160
|
+
>
|
|
161
|
+
<TableCell key={'drag'}>
|
|
162
|
+
<MenuIcon sx={{ cursor: 'pointer' }} className='handle' />
|
|
163
|
+
</TableCell>
|
|
164
|
+
{expand && (
|
|
165
|
+
<TableCell
|
|
166
|
+
padding='none'
|
|
167
|
+
className={DatagridClasses.expandIconCell}
|
|
168
|
+
>
|
|
169
|
+
{expandable && (
|
|
170
|
+
<ExpandRowButton
|
|
171
|
+
className={clsx(DatagridClasses.expandIcon, {
|
|
172
|
+
[DatagridClasses.expanded]: expanded,
|
|
173
|
+
})}
|
|
174
|
+
expanded={expanded}
|
|
175
|
+
onClick={handleToggleExpand}
|
|
176
|
+
expandContentId={`${id}-expand`}
|
|
177
|
+
/>
|
|
178
|
+
)}
|
|
179
|
+
</TableCell>
|
|
180
|
+
)}
|
|
181
|
+
{hasBulkActions && (
|
|
182
|
+
<TableCell padding='checkbox'>
|
|
183
|
+
<Checkbox
|
|
184
|
+
aria-label={translate('ra.action.select_row', {
|
|
185
|
+
_: 'Select this row',
|
|
186
|
+
})}
|
|
187
|
+
color='primary'
|
|
188
|
+
className={`select-item ${DatagridClasses.checkbox}`}
|
|
189
|
+
checked={selectable && selected}
|
|
190
|
+
onClick={handleToggleSelection}
|
|
191
|
+
disabled={!selectable}
|
|
192
|
+
/>
|
|
193
|
+
</TableCell>
|
|
194
|
+
)}
|
|
195
|
+
{React.Children.map(children, (field, index) =>
|
|
196
|
+
isValidElement(field) ? (
|
|
197
|
+
<DatagridCell
|
|
198
|
+
key={`${id}-${(field.props as any).source || index}`}
|
|
199
|
+
className={clsx(
|
|
200
|
+
`column-${(field.props as any).source}`,
|
|
201
|
+
DatagridClasses.rowCell,
|
|
202
|
+
)}
|
|
203
|
+
record={record}
|
|
204
|
+
{...{ field, resource }}
|
|
205
|
+
/>
|
|
206
|
+
) : null,
|
|
207
|
+
)}
|
|
208
|
+
</TableRow>
|
|
209
|
+
{expandable && expanded && (
|
|
210
|
+
<TableRow
|
|
211
|
+
key={`${id}-expand`}
|
|
212
|
+
id={`${id}-expand`}
|
|
213
|
+
className={DatagridClasses.expandedPanel}
|
|
214
|
+
>
|
|
215
|
+
<TableCell colSpan={nbColumns}>
|
|
216
|
+
{isElement(expand)
|
|
217
|
+
/* @ts-ignore */
|
|
218
|
+
? cloneElement(expand, {
|
|
219
|
+
record,
|
|
220
|
+
resource,
|
|
221
|
+
id: String(id),
|
|
222
|
+
})
|
|
223
|
+
/* @ts-ignore */
|
|
224
|
+
: createElement(expand, {
|
|
225
|
+
record,
|
|
226
|
+
resource,
|
|
227
|
+
id: String(id),
|
|
228
|
+
})}
|
|
229
|
+
</TableCell>
|
|
230
|
+
</TableRow>
|
|
231
|
+
)}
|
|
232
|
+
</RecordContextProvider>
|
|
233
|
+
);
|
|
234
|
+
},
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
const areEqual = (prevProps, nextProps) => {
|
|
238
|
+
const { children: _1, expand: _2, ...prevPropsWithoutChildren } = prevProps;
|
|
239
|
+
const { children: _3, expand: _4, ...nextPropsWithoutChildren } = nextProps;
|
|
240
|
+
return shallowEqual(prevPropsWithoutChildren, nextPropsWithoutChildren);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export const PureDatagridRow = memo(DatagridRow, areEqual);
|
|
244
|
+
|
|
245
|
+
PureDatagridRow.displayName = 'PureDatagridRow';
|
|
246
|
+
|
|
247
|
+
export default SortableDatagridRow;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { IconButton } from '@mui/material';
|
|
2
|
+
import { FC, useState } from 'react';
|
|
3
|
+
import { Upload } from '@mui/icons-material';
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
export interface ISingleImageUploader {
|
|
7
|
+
classNamePrefix?: string;
|
|
8
|
+
currentUrl?: string;
|
|
9
|
+
onChange?: (file:File) => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const SingleImageUploader:FC<ISingleImageUploader> = (props) => {
|
|
13
|
+
|
|
14
|
+
const { classNamePrefix = 'default', currentUrl = 'single-image-uploader', onChange } = props;
|
|
15
|
+
|
|
16
|
+
const [localFile, setLocalFile] = useState(null);
|
|
17
|
+
|
|
18
|
+
return <div className={`single-image-uploader ${classNamePrefix}-img`}>
|
|
19
|
+
{localFile || currentUrl ? (
|
|
20
|
+
<img src={localFile || currentUrl} alt='' />
|
|
21
|
+
) : (
|
|
22
|
+
<div className={`${classNamePrefix}-icon`}>
|
|
23
|
+
{/*<Image />*/}
|
|
24
|
+
</div>
|
|
25
|
+
)}
|
|
26
|
+
<IconButton
|
|
27
|
+
aria-label='upload image'
|
|
28
|
+
component='label'
|
|
29
|
+
className={`${classNamePrefix}-edit`}
|
|
30
|
+
>
|
|
31
|
+
<Upload style={{ opacity: '0.6' }} />
|
|
32
|
+
|
|
33
|
+
<input
|
|
34
|
+
hidden
|
|
35
|
+
accept='image/*'
|
|
36
|
+
type='file'
|
|
37
|
+
onChange={e => {
|
|
38
|
+
|
|
39
|
+
setLocalFile(URL.createObjectURL(e.target.files[0]));
|
|
40
|
+
|
|
41
|
+
if (onChange) {
|
|
42
|
+
onChange(e.target.files[0]);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}}
|
|
46
|
+
/>
|
|
47
|
+
|
|
48
|
+
{/*<Edit
|
|
49
|
+
style={{ opacity: '0.6' }}
|
|
50
|
+
/>*/}
|
|
51
|
+
</IconButton>
|
|
52
|
+
</div>;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default SingleImageUploader;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RadioGroup,
|
|
3
|
+
ListItem,
|
|
4
|
+
ListItemText,
|
|
5
|
+
Button,
|
|
6
|
+
List,
|
|
7
|
+
} from '@mui/material';
|
|
8
|
+
import { FC, useState, useEffect } from 'react';
|
|
9
|
+
import { UseFormGetValues, UseFormSetValue } from 'react-hook-form';
|
|
10
|
+
import { IPackagePayload } from 'dash-interfaces';
|
|
11
|
+
import { AppDialogOptions } from 'dash-dialog/src/IAppDialogProps';
|
|
12
|
+
|
|
13
|
+
export interface IPackageCopyMethod {
|
|
14
|
+
defaultCopyMethod: number;
|
|
15
|
+
dialog: (options: AppDialogOptions) => void;
|
|
16
|
+
sendPackage: (data: any) => Promise<void>;
|
|
17
|
+
resetExtraPayloadFlagsAfterSubmit: () => void;
|
|
18
|
+
getValues: UseFormGetValues<IPackagePayload>;
|
|
19
|
+
setValue: UseFormSetValue<IPackagePayload>;
|
|
20
|
+
onChange?: (copy_method: number) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const PackageCopyMethod: FC<IPackageCopyMethod> = (props) => {
|
|
24
|
+
const {
|
|
25
|
+
onChange,
|
|
26
|
+
defaultCopyMethod,
|
|
27
|
+
dialog,
|
|
28
|
+
sendPackage,
|
|
29
|
+
resetExtraPayloadFlagsAfterSubmit,
|
|
30
|
+
getValues,
|
|
31
|
+
setValue,
|
|
32
|
+
} = props;
|
|
33
|
+
|
|
34
|
+
const [selectedCopyMethod, setSelectedCopyMethod] = useState<number>();
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* "copy_method" = 1: solo botón que indique "Ingresar Nuevamente" ya que este paquete fue antes duplicado
|
|
38
|
+
* "copy_method" = 2: debe haber un boton que indique "Ingresar Nuevamente" y otro que indique "Duplicado"
|
|
39
|
+
* Ambos botones deben enviar de nuevo el formulario pero con el nuevo input "copy_method" segun el boton presionado
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (onChange) { onChange(selectedCopyMethod); }
|
|
44
|
+
}, [selectedCopyMethod]);
|
|
45
|
+
|
|
46
|
+
const selectCopyMethod = (copy_method: number) => {
|
|
47
|
+
setValue('copy_method', copy_method);
|
|
48
|
+
setSelectedCopyMethod(copy_method);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<RadioGroup
|
|
53
|
+
aria-labelledby='copy-method-selection-label'
|
|
54
|
+
defaultValue={defaultCopyMethod}
|
|
55
|
+
name='copy-method-selection'
|
|
56
|
+
>
|
|
57
|
+
<List>
|
|
58
|
+
<ListItem key={'copy_method_1'}>
|
|
59
|
+
<ListItemText
|
|
60
|
+
primary={
|
|
61
|
+
<Button
|
|
62
|
+
onClick={() => {
|
|
63
|
+
selectCopyMethod(1);
|
|
64
|
+
/** sendPackage with current react hook form values, instead of default formSubmit event */
|
|
65
|
+
sendPackage(getValues());
|
|
66
|
+
/** resets copy_method & high_value possible updated form state props in dialog */
|
|
67
|
+
resetExtraPayloadFlagsAfterSubmit();
|
|
68
|
+
dialog(null);
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
Ingresar Nuevamente
|
|
72
|
+
</Button>
|
|
73
|
+
}
|
|
74
|
+
/>
|
|
75
|
+
</ListItem>
|
|
76
|
+
|
|
77
|
+
<ListItem key={'copy_method_2'}>
|
|
78
|
+
{/*<Radio
|
|
79
|
+
onChange={(e) =>
|
|
80
|
+
selectCopyMethod(e.target.value as unknown as number)
|
|
81
|
+
}
|
|
82
|
+
value={2}
|
|
83
|
+
name="copy-method-selection"
|
|
84
|
+
inputProps={{ "aria-label": "2" }}
|
|
85
|
+
/>*/}
|
|
86
|
+
|
|
87
|
+
<ListItemText
|
|
88
|
+
primary={
|
|
89
|
+
<Button
|
|
90
|
+
onClick={() => {
|
|
91
|
+
selectCopyMethod(2);
|
|
92
|
+
/** sendPackage with current react hook form values, instead of default formSubmit event */
|
|
93
|
+
sendPackage(getValues());
|
|
94
|
+
/** resets copy_method & high_value possible updated form state props in dialog */
|
|
95
|
+
resetExtraPayloadFlagsAfterSubmit();
|
|
96
|
+
dialog(null);
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
Duplicado
|
|
100
|
+
</Button>
|
|
101
|
+
}
|
|
102
|
+
/>
|
|
103
|
+
</ListItem>
|
|
104
|
+
</List>
|
|
105
|
+
</RadioGroup>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default PackageCopyMethod;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
import { RadioGroup, ListItem, ListItemText, Radio, List } from '@mui/material';
|
|
3
|
+
import { FC, useState } from 'react';
|
|
4
|
+
import { IPackage } from 'dash-interfaces';
|
|
5
|
+
export interface IPackagesRadioButtonsGroup {
|
|
6
|
+
packages: IPackage[];
|
|
7
|
+
onChange?: (value: string) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const PackagesRadioButtonsGroup: FC<IPackagesRadioButtonsGroup> = (props) => {
|
|
11
|
+
const { packages, onChange } = props;
|
|
12
|
+
const [value, setValue] = useState<string>(null);
|
|
13
|
+
|
|
14
|
+
const handleChange = (event:any) => {
|
|
15
|
+
setValue(event.target.value);
|
|
16
|
+
if (onChange) { onChange(event.target.value); }
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<RadioGroup
|
|
21
|
+
aria-labelledby='package-selection-label'
|
|
22
|
+
name='package-selection'
|
|
23
|
+
>
|
|
24
|
+
<List>
|
|
25
|
+
{packages.map((p, index) => {
|
|
26
|
+
return (
|
|
27
|
+
<ListItem key={index}>
|
|
28
|
+
<Radio
|
|
29
|
+
checked={value === p.id.toString()}
|
|
30
|
+
onChange={handleChange}
|
|
31
|
+
value={p.id}
|
|
32
|
+
name='package-selection'
|
|
33
|
+
inputProps={{ 'aria-label': p.id.toString() }}
|
|
34
|
+
/>
|
|
35
|
+
<ListItemText
|
|
36
|
+
primary={p.id}
|
|
37
|
+
secondary={`Internal Id: ${p.internal_id}, Dirección: ${p.delivery_address}`}
|
|
38
|
+
/>
|
|
39
|
+
</ListItem>
|
|
40
|
+
);
|
|
41
|
+
})}
|
|
42
|
+
</List>
|
|
43
|
+
</RadioGroup>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default PackagesRadioButtonsGroup;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const DialogBasic = () => {
|
|
2
|
+
return (
|
|
3
|
+
<span>
|
|
4
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam ante est,
|
|
5
|
+
hendrerit quis bibendum eget, sodales vitae libero. Mauris a dolor vel
|
|
6
|
+
neque euismod tempor.
|
|
7
|
+
</span>
|
|
8
|
+
);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default DialogBasic;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
const DialogCorrect = () => {
|
|
3
|
+
return (
|
|
4
|
+
<>
|
|
5
|
+
<p>
|
|
6
|
+
<strong>Paquete ingresado correctamente</strong>
|
|
7
|
+
</p>
|
|
8
|
+
<p>
|
|
9
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean pharetra
|
|
10
|
+
libero vitae cursus gravida,{' '}
|
|
11
|
+
</p>
|
|
12
|
+
</>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default DialogCorrect;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const DialogError = () => {
|
|
2
|
+
return (
|
|
3
|
+
<>
|
|
4
|
+
<p>
|
|
5
|
+
<strong>El paquete no pudo ser ingresado</strong>
|
|
6
|
+
</p>
|
|
7
|
+
<p>
|
|
8
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean pharetra
|
|
9
|
+
libero vitae cursus gravida,{' '}
|
|
10
|
+
</p>
|
|
11
|
+
</>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default DialogError;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const DialogInfo = () => {
|
|
2
|
+
return (
|
|
3
|
+
<>
|
|
4
|
+
<p>
|
|
5
|
+
<strong>Despachos realizados</strong>
|
|
6
|
+
</p>
|
|
7
|
+
<p>
|
|
8
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean pharetra
|
|
9
|
+
libero vitae cursus gravida,{' '}
|
|
10
|
+
</p>
|
|
11
|
+
</>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default DialogInfo;
|