@etsoo/react 1.4.40 → 1.4.41

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.
@@ -8,6 +8,7 @@ export declare namespace Labels {
8
8
  */
9
9
  const CommonPage: {
10
10
  add: string;
11
+ delete: string;
11
12
  more: string;
12
13
  pullToRefresh: string;
13
14
  refresh: string;
package/lib/app/Labels.js CHANGED
@@ -9,6 +9,7 @@ export var Labels;
9
9
  */
10
10
  Labels.CommonPage = {
11
11
  add: 'Add',
12
+ delete: 'Delete',
12
13
  more: 'More',
13
14
  pullToRefresh: 'Pull down to refresh',
14
15
  refresh: 'Refresh',
@@ -67,7 +67,7 @@ export var DataGridRenderers;
67
67
  if (value)
68
68
  return React.createElement(CheckIcon, { fontSize: "small" });
69
69
  else
70
- return React.createElement(ClearIcon, { fontSize: "small", color: "error" });
70
+ return React.createElement(ClearIcon, { fontSize: "small", color: "warning" });
71
71
  }
72
72
  // To string
73
73
  return new String(value);
@@ -4,10 +4,18 @@ import { CommonPageProps } from './CommonPageProps';
4
4
  * Add / Edit page props
5
5
  */
6
6
  export interface EditPageProps extends Omit<CommonPageProps, 'onSubmit'> {
7
+ /**
8
+ * Is editing
9
+ */
10
+ isEditing?: boolean;
7
11
  /**
8
12
  * On form submit
9
13
  */
10
14
  onSubmit?: FormEventHandler<HTMLFormElement>;
15
+ /**
16
+ * On delete callback
17
+ */
18
+ onDelete?: () => Promise<void> | void;
11
19
  }
12
20
  /**
13
21
  * Add / Edit page
@@ -4,22 +4,24 @@ import { Labels } from '../../app/Labels';
4
4
  import { MUGlobal } from '../MUGlobal';
5
5
  import { CommonPage, CommonPageScrollContainer } from './CommonPage';
6
6
  import SaveIcon from '@mui/icons-material/Save';
7
+ import DeleteIcon from '@mui/icons-material/Delete';
7
8
  /**
8
9
  * Add / Edit page
9
10
  * @param props Props
10
11
  */
11
12
  export function EditPage(props) {
12
13
  // Destruct
13
- const { children, onSubmit, paddings = MUGlobal.pagePaddings, scrollContainer = CommonPageScrollContainer, ...rest } = props;
14
+ const { children, isEditing, onDelete, onSubmit, paddings = MUGlobal.pagePaddings, scrollContainer = CommonPageScrollContainer, ...rest } = props;
14
15
  // Labels
15
16
  const labels = Labels.CommonPage;
16
17
  return (React.createElement(CommonPage, { paddings: paddings, scrollContainer: scrollContainer, ...rest },
17
18
  React.createElement("form", { onSubmit: onSubmit },
18
19
  React.createElement(Grid, { container: true, justifyContent: "left", spacing: paddings, paddingTop: 1 }, children),
19
- React.createElement(Grid, { container: true, position: "sticky", sx: {
20
+ React.createElement(Grid, { container: true, position: "sticky", display: "flex", gap: paddings, sx: {
20
21
  top: 'auto',
21
22
  bottom: (theme) => MUGlobal.updateWithTheme(paddings, theme.spacing),
22
23
  paddingTop: paddings
23
24
  } },
24
- React.createElement(Button, { variant: "contained", type: "submit", fullWidth: true, startIcon: React.createElement(SaveIcon, null) }, labels.save)))));
25
+ isEditing && onDelete && (React.createElement(Button, { color: "primary", variant: "outlined", onClick: () => onDelete(), startIcon: React.createElement(DeleteIcon, { color: "warning" }) }, labels.delete)),
26
+ React.createElement(Button, { variant: "contained", type: "submit", fullWidth: true, startIcon: React.createElement(SaveIcon, null), sx: { flexGrow: 1 } }, labels.save)))));
25
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.4.40",
3
+ "version": "1.4.41",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/app/Labels.ts CHANGED
@@ -9,6 +9,7 @@ export namespace Labels {
9
9
  */
10
10
  export const CommonPage = {
11
11
  add: 'Add',
12
+ delete: 'Delete',
12
13
  more: 'More',
13
14
  pullToRefresh: 'Pull down to refresh',
14
15
  refresh: 'Refresh',
@@ -103,7 +103,7 @@ export namespace DataGridRenderers {
103
103
  }
104
104
 
105
105
  if (value) return <CheckIcon fontSize="small" />;
106
- else return <ClearIcon fontSize="small" color="error" />;
106
+ else return <ClearIcon fontSize="small" color="warning" />;
107
107
  }
108
108
 
109
109
  // To string
@@ -5,15 +5,26 @@ import { MUGlobal } from '../MUGlobal';
5
5
  import { CommonPage, CommonPageScrollContainer } from './CommonPage';
6
6
  import { CommonPageProps } from './CommonPageProps';
7
7
  import SaveIcon from '@mui/icons-material/Save';
8
+ import DeleteIcon from '@mui/icons-material/Delete';
8
9
 
9
10
  /**
10
11
  * Add / Edit page props
11
12
  */
12
13
  export interface EditPageProps extends Omit<CommonPageProps, 'onSubmit'> {
14
+ /**
15
+ * Is editing
16
+ */
17
+ isEditing?: boolean;
18
+
13
19
  /**
14
20
  * On form submit
15
21
  */
16
22
  onSubmit?: FormEventHandler<HTMLFormElement>;
23
+
24
+ /**
25
+ * On delete callback
26
+ */
27
+ onDelete?: () => Promise<void> | void;
17
28
  }
18
29
 
19
30
  /**
@@ -24,6 +35,8 @@ export function EditPage(props: EditPageProps) {
24
35
  // Destruct
25
36
  const {
26
37
  children,
38
+ isEditing,
39
+ onDelete,
27
40
  onSubmit,
28
41
  paddings = MUGlobal.pagePaddings,
29
42
  scrollContainer = CommonPageScrollContainer,
@@ -51,6 +64,8 @@ export function EditPage(props: EditPageProps) {
51
64
  <Grid
52
65
  container
53
66
  position="sticky"
67
+ display="flex"
68
+ gap={paddings}
54
69
  sx={{
55
70
  top: 'auto',
56
71
  bottom: (theme) =>
@@ -58,11 +73,22 @@ export function EditPage(props: EditPageProps) {
58
73
  paddingTop: paddings
59
74
  }}
60
75
  >
76
+ {isEditing && onDelete && (
77
+ <Button
78
+ color="primary"
79
+ variant="outlined"
80
+ onClick={() => onDelete()}
81
+ startIcon={<DeleteIcon color="warning" />}
82
+ >
83
+ {labels.delete}
84
+ </Button>
85
+ )}
61
86
  <Button
62
87
  variant="contained"
63
88
  type="submit"
64
89
  fullWidth
65
90
  startIcon={<SaveIcon />}
91
+ sx={{ flexGrow: 1 }}
66
92
  >
67
93
  {labels.save}
68
94
  </Button>