@etsoo/react 1.5.49 → 1.5.52

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) => {
@@ -107,6 +134,33 @@ test('Prompt tests', async () => {
107
134
  jest.runOnlyPendingTimers();
108
135
  });
109
136
 
137
+ test('Prompt tests with form submit', async () => {
138
+ // Click
139
+ const handleClick = jest.fn((result: boolean) => {
140
+ expect(result).toBeTruthy();
141
+ });
142
+
143
+ act(() => {
144
+ // Add the notification
145
+ notifier.prompt<boolean>('Prompt message', handleClick, undefined, {
146
+ type: 'switch',
147
+ required: false
148
+ });
149
+ });
150
+
151
+ await act(async () => {
152
+ (
153
+ root
154
+ .getElementsByTagName('form')[0]
155
+ .elements.namedItem('okButton') as HTMLButtonElement
156
+ )?.click();
157
+ });
158
+
159
+ expect(handleClick).toBeCalled();
160
+
161
+ jest.runOnlyPendingTimers();
162
+ });
163
+
110
164
  test('Message tests', (done) => {
111
165
  // Callback
112
166
  const callback = jest.fn(() => done());
@@ -200,7 +200,12 @@ export class NotificationMU extends NotificationReact {
200
200
  localInputs = inputs;
201
201
  }
202
202
  return (React.createElement(Dialog, { key: this.id, open: this.open, PaperComponent: DraggablePaperComponent, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen },
203
- React.createElement("form", null,
203
+ React.createElement("form", { onSubmit: (event) => {
204
+ var _a;
205
+ event.preventDefault();
206
+ (_a = event.currentTarget.elements.namedItem('okButton')) === null || _a === void 0 ? void 0 : _a.click();
207
+ return false;
208
+ } },
204
209
  React.createElement(IconDialogTitle, { className: "draggable-dialog-title" },
205
210
  React.createElement(Info, { color: "primary" }),
206
211
  React.createElement("span", { className: "dialogTitle" }, title)),
@@ -214,7 +219,7 @@ export class NotificationMU extends NotificationReact {
214
219
  this.onReturn(undefined);
215
220
  this.dismiss();
216
221
  } }, cancelLabel)),
217
- React.createElement(LoadingButton, { color: "primary", autoFocus: true, onClick: handleSubmit, ...primaryButton }, okLabel)))));
222
+ React.createElement(LoadingButton, { color: "primary", autoFocus: true, onClick: handleSubmit, name: "okButton", ...primaryButton }, okLabel)))));
218
223
  }
219
224
  // Create loading
220
225
  createLoading(_props, className) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.5.49",
3
+ "version": "1.5.52",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -48,9 +48,8 @@
48
48
  "dependencies": {
49
49
  "@emotion/css": "^11.9.0",
50
50
  "@emotion/react": "^11.9.3",
51
- "@emotion/style": "^0.8.0",
52
51
  "@emotion/styled": "^11.9.3",
53
- "@etsoo/appscript": "^1.2.62",
52
+ "@etsoo/appscript": "^1.2.63",
54
53
  "@etsoo/notificationbase": "^1.1.4",
55
54
  "@etsoo/shared": "^1.1.40",
56
55
  "@mui/icons-material": "^5.8.4",
@@ -358,7 +358,17 @@ export class NotificationMU extends NotificationReact {
358
358
  maxWidth={maxWidth}
359
359
  fullScreen={fullScreen}
360
360
  >
361
- <form>
361
+ <form
362
+ onSubmit={(event) => {
363
+ event.preventDefault();
364
+ (
365
+ event.currentTarget.elements.namedItem(
366
+ 'okButton'
367
+ ) as HTMLButtonElement
368
+ )?.click();
369
+ return false;
370
+ }}
371
+ >
362
372
  <IconDialogTitle className="draggable-dialog-title">
363
373
  <Info color="primary" />
364
374
  <span className="dialogTitle">{title}</span>
@@ -389,6 +399,7 @@ export class NotificationMU extends NotificationReact {
389
399
  color="primary"
390
400
  autoFocus
391
401
  onClick={handleSubmit}
402
+ name="okButton"
392
403
  {...primaryButton}
393
404
  >
394
405
  {okLabel}