@etsoo/react 1.5.50 → 1.5.51

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.
@@ -134,6 +134,33 @@ test('Prompt tests', async () => {
134
134
  jest.runOnlyPendingTimers();
135
135
  });
136
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
+
137
164
  test('Message tests', (done) => {
138
165
  // Callback
139
166
  const callback = jest.fn(() => done());
@@ -200,7 +200,10 @@ 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
+ return (_a = event.currentTarget.elements.namedItem('okButton')) === null || _a === void 0 ? void 0 : _a.click();
206
+ } },
204
207
  React.createElement(IconDialogTitle, { className: "draggable-dialog-title" },
205
208
  React.createElement(Info, { color: "primary" }),
206
209
  React.createElement("span", { className: "dialogTitle" }, title)),
@@ -214,7 +217,7 @@ export class NotificationMU extends NotificationReact {
214
217
  this.onReturn(undefined);
215
218
  this.dismiss();
216
219
  } }, cancelLabel)),
217
- React.createElement(LoadingButton, { color: "primary", autoFocus: true, onClick: handleSubmit, ...primaryButton }, okLabel)))));
220
+ React.createElement(LoadingButton, { color: "primary", autoFocus: true, onClick: handleSubmit, name: "okButton", ...primaryButton }, okLabel)))));
218
221
  }
219
222
  // Create loading
220
223
  createLoading(_props, className) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.5.50",
3
+ "version": "1.5.51",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -358,7 +358,15 @@ export class NotificationMU extends NotificationReact {
358
358
  maxWidth={maxWidth}
359
359
  fullScreen={fullScreen}
360
360
  >
361
- <form>
361
+ <form
362
+ onSubmit={(event) =>
363
+ (
364
+ event.currentTarget.elements.namedItem(
365
+ 'okButton'
366
+ ) as HTMLButtonElement
367
+ )?.click()
368
+ }
369
+ >
362
370
  <IconDialogTitle className="draggable-dialog-title">
363
371
  <Info color="primary" />
364
372
  <span className="dialogTitle">{title}</span>
@@ -389,6 +397,7 @@ export class NotificationMU extends NotificationReact {
389
397
  color="primary"
390
398
  autoFocus
391
399
  onClick={handleSubmit}
400
+ name="okButton"
392
401
  {...primaryButton}
393
402
  >
394
403
  {okLabel}