@etsoo/react 1.2.16 → 1.2.17
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/lib/mu/DialogButton.d.ts +15 -0
- package/lib/mu/DialogButton.js +14 -7
- package/package.json +1 -1
- package/src/mu/DialogButton.tsx +39 -5
package/lib/mu/DialogButton.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Breakpoint, ButtonProps } from '@mui/material';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export interface DialogButtonProps extends ButtonProps {
|
|
4
|
+
/**
|
|
5
|
+
* Button label
|
|
6
|
+
*/
|
|
7
|
+
buttonLabel?: string;
|
|
4
8
|
/**
|
|
5
9
|
* Dialog content
|
|
6
10
|
*/
|
|
@@ -22,6 +26,17 @@ export interface DialogButtonProps extends ButtonProps {
|
|
|
22
26
|
* Show fullscreen dialog
|
|
23
27
|
*/
|
|
24
28
|
fullScreen?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* If `true`, the dialog stretches to `maxWidth`.
|
|
31
|
+
*
|
|
32
|
+
* Notice that the dialog width grow is limited by the default margin.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
fullWidth?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Other layouts
|
|
38
|
+
*/
|
|
39
|
+
inputs?: React.ReactNode;
|
|
25
40
|
/**
|
|
26
41
|
* Max width of the dialog
|
|
27
42
|
*/
|
package/lib/mu/DialogButton.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { Button, Dialog, DialogContent, DialogContentText, DialogTitle, IconButton } from '@mui/material';
|
|
1
|
+
import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, IconButton } from '@mui/material';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { Labels } from '../app/Labels';
|
|
3
4
|
/**
|
|
4
5
|
* Dialog button
|
|
5
6
|
* @param props Props
|
|
6
7
|
* @returns Component
|
|
7
8
|
*/
|
|
8
9
|
export function DialogButton(props) {
|
|
10
|
+
// Labels shared with NotificationMU
|
|
11
|
+
const labels = Labels.NotificationMU;
|
|
9
12
|
// Destruct
|
|
10
|
-
const { children, content, contentPre, dialogTitle, disableScrollLock, fullScreen, icon, maxWidth, onClick, ...rest } = props;
|
|
13
|
+
const { buttonLabel = labels.alertOK, children, content, contentPre, dialogTitle, disableScrollLock, fullScreen, fullWidth, icon, inputs, maxWidth, onClick, ...rest } = props;
|
|
11
14
|
// Open state
|
|
12
15
|
const [open, setOpen] = React.useState(false);
|
|
13
16
|
const handleClickOpen = () => {
|
|
14
17
|
setOpen(true);
|
|
15
18
|
};
|
|
16
|
-
const handleClose = () => {
|
|
17
|
-
setOpen(false);
|
|
18
|
-
};
|
|
19
19
|
// Onclick handler
|
|
20
20
|
const onClickLocal = (event) => {
|
|
21
21
|
// Stop propagation
|
|
@@ -30,8 +30,15 @@ export function DialogButton(props) {
|
|
|
30
30
|
// Layout
|
|
31
31
|
return (React.createElement(React.Fragment, null,
|
|
32
32
|
icon == null ? (React.createElement(Button, { ...rest, onClick: onClickLocal }, children)) : (React.createElement(IconButton, { ...rest, onClick: onClickLocal, title: children === null || children === void 0 ? void 0 : children.toString() }, icon)),
|
|
33
|
-
React.createElement(Dialog, { disableScrollLock: disableScrollLock, fullScreen: fullScreen, maxWidth: maxWidth, open: open, onClose:
|
|
33
|
+
React.createElement(Dialog, { disableScrollLock: disableScrollLock, fullScreen: fullScreen, fullWidth: fullWidth, maxWidth: maxWidth, open: open, onClose: () => setOpen(false), onClick: (event) => {
|
|
34
|
+
// The dialog will be embeded and the click event will bubble up
|
|
35
|
+
// Stop propatation but will also cancel onClose and onBackdropClick event
|
|
36
|
+
event.stopPropagation();
|
|
37
|
+
} },
|
|
34
38
|
React.createElement(DialogTitle, null, dialogTitle ? dialogTitle : children),
|
|
35
39
|
React.createElement(DialogContent, null,
|
|
36
|
-
React.createElement(DialogContentText, { component: contentPre ? 'pre' : 'span' }, content)
|
|
40
|
+
React.createElement(DialogContentText, { component: contentPre ? 'pre' : 'span' }, content),
|
|
41
|
+
inputs),
|
|
42
|
+
React.createElement(DialogActions, null,
|
|
43
|
+
React.createElement(Button, { onClick: () => setOpen(false) }, buttonLabel)))));
|
|
37
44
|
}
|
package/package.json
CHANGED
package/src/mu/DialogButton.tsx
CHANGED
|
@@ -3,14 +3,21 @@ import {
|
|
|
3
3
|
Button,
|
|
4
4
|
ButtonProps,
|
|
5
5
|
Dialog,
|
|
6
|
+
DialogActions,
|
|
6
7
|
DialogContent,
|
|
7
8
|
DialogContentText,
|
|
8
9
|
DialogTitle,
|
|
9
10
|
IconButton
|
|
10
11
|
} from '@mui/material';
|
|
11
12
|
import React from 'react';
|
|
13
|
+
import { Labels } from '../app/Labels';
|
|
12
14
|
|
|
13
15
|
export interface DialogButtonProps extends ButtonProps {
|
|
16
|
+
/**
|
|
17
|
+
* Button label
|
|
18
|
+
*/
|
|
19
|
+
buttonLabel?: string;
|
|
20
|
+
|
|
14
21
|
/**
|
|
15
22
|
* Dialog content
|
|
16
23
|
*/
|
|
@@ -37,6 +44,19 @@ export interface DialogButtonProps extends ButtonProps {
|
|
|
37
44
|
*/
|
|
38
45
|
fullScreen?: boolean;
|
|
39
46
|
|
|
47
|
+
/**
|
|
48
|
+
* If `true`, the dialog stretches to `maxWidth`.
|
|
49
|
+
*
|
|
50
|
+
* Notice that the dialog width grow is limited by the default margin.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
fullWidth?: boolean;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Other layouts
|
|
57
|
+
*/
|
|
58
|
+
inputs?: React.ReactNode;
|
|
59
|
+
|
|
40
60
|
/**
|
|
41
61
|
* Max width of the dialog
|
|
42
62
|
*/
|
|
@@ -54,15 +74,21 @@ export interface DialogButtonProps extends ButtonProps {
|
|
|
54
74
|
* @returns Component
|
|
55
75
|
*/
|
|
56
76
|
export function DialogButton(props: DialogButtonProps) {
|
|
77
|
+
// Labels shared with NotificationMU
|
|
78
|
+
const labels = Labels.NotificationMU;
|
|
79
|
+
|
|
57
80
|
// Destruct
|
|
58
81
|
const {
|
|
82
|
+
buttonLabel = labels.alertOK,
|
|
59
83
|
children,
|
|
60
84
|
content,
|
|
61
85
|
contentPre,
|
|
62
86
|
dialogTitle,
|
|
63
87
|
disableScrollLock,
|
|
64
88
|
fullScreen,
|
|
89
|
+
fullWidth,
|
|
65
90
|
icon,
|
|
91
|
+
inputs,
|
|
66
92
|
maxWidth,
|
|
67
93
|
onClick,
|
|
68
94
|
...rest
|
|
@@ -75,10 +101,6 @@ export function DialogButton(props: DialogButtonProps) {
|
|
|
75
101
|
setOpen(true);
|
|
76
102
|
};
|
|
77
103
|
|
|
78
|
-
const handleClose = () => {
|
|
79
|
-
setOpen(false);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
104
|
// Onclick handler
|
|
83
105
|
const onClickLocal = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
84
106
|
// Stop propagation
|
|
@@ -112,9 +134,15 @@ export function DialogButton(props: DialogButtonProps) {
|
|
|
112
134
|
<Dialog
|
|
113
135
|
disableScrollLock={disableScrollLock}
|
|
114
136
|
fullScreen={fullScreen}
|
|
137
|
+
fullWidth={fullWidth}
|
|
115
138
|
maxWidth={maxWidth}
|
|
116
139
|
open={open}
|
|
117
|
-
onClose={
|
|
140
|
+
onClose={() => setOpen(false)}
|
|
141
|
+
onClick={(event) => {
|
|
142
|
+
// The dialog will be embeded and the click event will bubble up
|
|
143
|
+
// Stop propatation but will also cancel onClose and onBackdropClick event
|
|
144
|
+
event.stopPropagation();
|
|
145
|
+
}}
|
|
118
146
|
>
|
|
119
147
|
<DialogTitle>
|
|
120
148
|
{dialogTitle ? dialogTitle : children}
|
|
@@ -123,7 +151,13 @@ export function DialogButton(props: DialogButtonProps) {
|
|
|
123
151
|
<DialogContentText component={contentPre ? 'pre' : 'span'}>
|
|
124
152
|
{content}
|
|
125
153
|
</DialogContentText>
|
|
154
|
+
{inputs}
|
|
126
155
|
</DialogContent>
|
|
156
|
+
<DialogActions>
|
|
157
|
+
<Button onClick={() => setOpen(false)}>
|
|
158
|
+
{buttonLabel}
|
|
159
|
+
</Button>
|
|
160
|
+
</DialogActions>
|
|
127
161
|
</Dialog>
|
|
128
162
|
</React.Fragment>
|
|
129
163
|
);
|