@etsoo/react 1.5.47 → 1.5.50
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.
|
@@ -78,6 +78,33 @@ test('Confirm tests', async () => {
|
|
|
78
78
|
jest.runOnlyPendingTimers();
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
+
test('Confirm tests without cancel button', async () => {
|
|
82
|
+
// Click
|
|
83
|
+
const handleClick = jest.fn();
|
|
84
|
+
|
|
85
|
+
act(() => {
|
|
86
|
+
// Add the notification
|
|
87
|
+
notifier.confirm('Confirm message', undefined, handleClick, {
|
|
88
|
+
cancelButton: false
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Button
|
|
93
|
+
const button = root.getElementsByTagName('button');
|
|
94
|
+
|
|
95
|
+
expect(button.length).toBe(1);
|
|
96
|
+
expect(button[0].innerHTML).toContain('OK');
|
|
97
|
+
|
|
98
|
+
await act(async () => {
|
|
99
|
+
button[0].click();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
expect(handleClick).toBeCalled();
|
|
103
|
+
|
|
104
|
+
// Fast forward
|
|
105
|
+
jest.runOnlyPendingTimers();
|
|
106
|
+
});
|
|
107
|
+
|
|
81
108
|
test('Prompt tests', async () => {
|
|
82
109
|
// Click
|
|
83
110
|
const handleClick = jest.fn((result: boolean) => {
|
package/lib/app/ServiceApp.js
CHANGED
package/lib/mu/NotifierMU.js
CHANGED
|
@@ -77,7 +77,7 @@ export class NotificationMU extends NotificationReact {
|
|
|
77
77
|
var _a, _b;
|
|
78
78
|
const labels = Labels.NotificationMU;
|
|
79
79
|
const title = (_a = this.title) !== null && _a !== void 0 ? _a : labels.confirmTitle;
|
|
80
|
-
const { okLabel = labels.confirmYes, cancelLabel = labels.confirmNo, inputs, fullScreen, fullWidth = true, maxWidth, primaryButton } = (_b = this.inputProps) !== null && _b !== void 0 ? _b : {};
|
|
80
|
+
const { okLabel = labels.confirmYes, cancelLabel = labels.confirmNo, cancelButton = true, inputs, fullScreen, fullWidth = true, maxWidth, primaryButton } = (_b = this.inputProps) !== null && _b !== void 0 ? _b : {};
|
|
81
81
|
return (React.createElement(Dialog, { key: this.id, open: this.open, PaperComponent: DraggablePaperComponent, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen },
|
|
82
82
|
React.createElement(IconDialogTitle, { className: "draggable-dialog-title" },
|
|
83
83
|
React.createElement(Help, { color: "action" }),
|
|
@@ -86,7 +86,7 @@ export class NotificationMU extends NotificationReact {
|
|
|
86
86
|
React.createElement(DialogContentText, null, this.content),
|
|
87
87
|
inputs),
|
|
88
88
|
React.createElement(DialogActions, null,
|
|
89
|
-
React.createElement(LoadingButton, { color: "secondary", onClick: async () => await this.returnValue(false) }, cancelLabel),
|
|
89
|
+
cancelButton && (React.createElement(LoadingButton, { color: "secondary", onClick: async () => await this.returnValue(false) }, cancelLabel)),
|
|
90
90
|
React.createElement(LoadingButton, { color: "primary", onClick: async () => await this.returnValue(true), autoFocus: true, ...primaryButton }, okLabel))));
|
|
91
91
|
}
|
|
92
92
|
createMessageColor() {
|
|
@@ -119,7 +119,7 @@ export class NotificationMU extends NotificationReact {
|
|
|
119
119
|
var _a, _b;
|
|
120
120
|
const labels = Labels.NotificationMU;
|
|
121
121
|
const title = (_a = this.title) !== null && _a !== void 0 ? _a : labels.promptTitle;
|
|
122
|
-
const { cancelLabel = labels.promptCancel, okLabel = labels.promptOK, inputs, type, fullScreen, fullWidth = true, maxWidth, primaryButton, ...rest } = (_b = this.inputProps) !== null && _b !== void 0 ? _b : {};
|
|
122
|
+
const { cancelLabel = labels.promptCancel, okLabel = labels.promptOK, cancelButton = true, inputs, type, fullScreen, fullWidth = true, maxWidth, primaryButton, ...rest } = (_b = this.inputProps) !== null && _b !== void 0 ? _b : {};
|
|
123
123
|
const inputRef = React.createRef();
|
|
124
124
|
const errorRef = React.createRef();
|
|
125
125
|
const setError = (error) => {
|
|
@@ -209,11 +209,11 @@ export class NotificationMU extends NotificationReact {
|
|
|
209
209
|
localInputs,
|
|
210
210
|
React.createElement(Typography, { variant: "caption", display: "block", ref: errorRef, color: (theme) => theme.palette.error.main })),
|
|
211
211
|
React.createElement(DialogActions, null,
|
|
212
|
-
React.createElement(Button, { color: "secondary", onClick: () => {
|
|
212
|
+
cancelButton && (React.createElement(Button, { color: "secondary", onClick: () => {
|
|
213
213
|
if (this.onReturn)
|
|
214
214
|
this.onReturn(undefined);
|
|
215
215
|
this.dismiss();
|
|
216
|
-
} }, cancelLabel),
|
|
216
|
+
} }, cancelLabel)),
|
|
217
217
|
React.createElement(LoadingButton, { color: "primary", autoFocus: true, onClick: handleSubmit, ...primaryButton }, okLabel)))));
|
|
218
218
|
}
|
|
219
219
|
// Create loading
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.50",
|
|
4
4
|
"description": "TypeScript ReactJs framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"@emotion/react": "^11.9.3",
|
|
51
51
|
"@emotion/style": "^0.8.0",
|
|
52
52
|
"@emotion/styled": "^11.9.3",
|
|
53
|
-
"@etsoo/appscript": "^1.2.
|
|
53
|
+
"@etsoo/appscript": "^1.2.63",
|
|
54
54
|
"@etsoo/notificationbase": "^1.1.4",
|
|
55
55
|
"@etsoo/shared": "^1.1.40",
|
|
56
56
|
"@mui/icons-material": "^5.8.4",
|
|
57
|
-
"@mui/material": "^5.9.
|
|
57
|
+
"@mui/material": "^5.9.2",
|
|
58
58
|
"@types/pica": "^9.0.1",
|
|
59
59
|
"@types/pulltorefreshjs": "^0.1.5",
|
|
60
60
|
"@types/react": "^18.0.15",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"@babel/runtime-corejs3": "^7.18.9",
|
|
83
83
|
"@types/jest": "^28.1.6",
|
|
84
84
|
"@types/react-test-renderer": "^18.0.0",
|
|
85
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
86
|
-
"@typescript-eslint/parser": "^5.
|
|
85
|
+
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
|
86
|
+
"@typescript-eslint/parser": "^5.31.0",
|
|
87
87
|
"eslint": "^8.20.0",
|
|
88
88
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
89
89
|
"eslint-plugin-import": "^2.26.0",
|
package/src/app/ServiceApp.ts
CHANGED
package/src/mu/NotifierMU.tsx
CHANGED
|
@@ -144,6 +144,7 @@ export class NotificationMU extends NotificationReact {
|
|
|
144
144
|
const {
|
|
145
145
|
okLabel = labels.confirmYes,
|
|
146
146
|
cancelLabel = labels.confirmNo,
|
|
147
|
+
cancelButton = true,
|
|
147
148
|
inputs,
|
|
148
149
|
fullScreen,
|
|
149
150
|
fullWidth = true,
|
|
@@ -170,12 +171,14 @@ export class NotificationMU extends NotificationReact {
|
|
|
170
171
|
{inputs}
|
|
171
172
|
</DialogContent>
|
|
172
173
|
<DialogActions>
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
174
|
+
{cancelButton && (
|
|
175
|
+
<LoadingButton
|
|
176
|
+
color="secondary"
|
|
177
|
+
onClick={async () => await this.returnValue(false)}
|
|
178
|
+
>
|
|
179
|
+
{cancelLabel}
|
|
180
|
+
</LoadingButton>
|
|
181
|
+
)}
|
|
179
182
|
<LoadingButton
|
|
180
183
|
color="primary"
|
|
181
184
|
onClick={async () => await this.returnValue(true)}
|
|
@@ -230,6 +233,7 @@ export class NotificationMU extends NotificationReact {
|
|
|
230
233
|
const {
|
|
231
234
|
cancelLabel = labels.promptCancel,
|
|
232
235
|
okLabel = labels.promptOK,
|
|
236
|
+
cancelButton = true,
|
|
233
237
|
inputs,
|
|
234
238
|
type,
|
|
235
239
|
fullScreen,
|
|
@@ -370,15 +374,17 @@ export class NotificationMU extends NotificationReact {
|
|
|
370
374
|
/>
|
|
371
375
|
</DialogContent>
|
|
372
376
|
<DialogActions>
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
377
|
+
{cancelButton && (
|
|
378
|
+
<Button
|
|
379
|
+
color="secondary"
|
|
380
|
+
onClick={() => {
|
|
381
|
+
if (this.onReturn) this.onReturn(undefined);
|
|
382
|
+
this.dismiss();
|
|
383
|
+
}}
|
|
384
|
+
>
|
|
385
|
+
{cancelLabel}
|
|
386
|
+
</Button>
|
|
387
|
+
)}
|
|
382
388
|
<LoadingButton
|
|
383
389
|
color="primary"
|
|
384
390
|
autoFocus
|
package/src/notifier/Notifier.ts
CHANGED