@etsoo/react 1.2.14 → 1.2.15
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/__tests__/mu/NotifierMUTests.tsx +1 -2
- package/lib/app/InputDialogProps.d.ts +2 -14
- package/lib/app/ReactApp.d.ts +19 -3
- package/lib/app/ReactApp.js +2 -7
- package/lib/mu/CountdownButton.d.ts +1 -1
- package/lib/mu/NotifierMU.d.ts +4 -5
- package/lib/mu/NotifierMU.js +36 -28
- package/lib/mu/TextFieldEx.d.ts +3 -3
- package/lib/notifier/Notifier.d.ts +41 -8
- package/lib/notifier/Notifier.js +3 -6
- package/package.json +3 -3
- package/src/app/InputDialogProps.ts +2 -16
- package/src/app/ReactApp.ts +23 -11
- package/src/mu/NotifierMU.tsx +62 -56
- package/src/mu/NotifierPromptProps.ts +2 -0
- package/src/notifier/Notifier.ts +68 -16
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import Done from '@mui/icons-material/Done';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import ReactDOM from 'react-dom';
|
|
4
3
|
import { act } from 'react-dom/test-utils';
|
|
@@ -102,7 +101,7 @@ test('Message tests', (done) => {
|
|
|
102
101
|
// Callback
|
|
103
102
|
const callback = jest.fn(() => done());
|
|
104
103
|
|
|
105
|
-
let n: INotification<React.ReactNode> | undefined;
|
|
104
|
+
let n: INotification<React.ReactNode, any> | undefined;
|
|
106
105
|
act(() => {
|
|
107
106
|
// Add the notification
|
|
108
107
|
n = notifier.message(
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { NotificationReturn } from '@etsoo/notificationbase';
|
|
2
|
+
import { NotificationReactCallProps } from '../notifier/Notifier';
|
|
3
3
|
/**
|
|
4
4
|
* Input dialog props
|
|
5
5
|
*/
|
|
6
|
-
export declare type InputDialogProps = {
|
|
6
|
+
export declare type InputDialogProps = NotificationReactCallProps & {
|
|
7
7
|
/**
|
|
8
8
|
* Title
|
|
9
9
|
*/
|
|
@@ -12,20 +12,8 @@ export declare type InputDialogProps = {
|
|
|
12
12
|
* Message
|
|
13
13
|
*/
|
|
14
14
|
message: string;
|
|
15
|
-
/**
|
|
16
|
-
* Inputs layout
|
|
17
|
-
*/
|
|
18
|
-
inputs: React.ReactNode;
|
|
19
15
|
/**
|
|
20
16
|
* Callback
|
|
21
17
|
*/
|
|
22
18
|
callback: NotificationReturn<HTMLFormElement>;
|
|
23
|
-
/**
|
|
24
|
-
* OK label
|
|
25
|
-
*/
|
|
26
|
-
okLabel?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Cancel label
|
|
29
|
-
*/
|
|
30
|
-
cancelLabel?: string;
|
|
31
19
|
};
|
package/lib/app/ReactApp.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CoreApp, IAppSettings, ICoreApp, IUser, IUserData } from '@etsoo/appscript';
|
|
2
2
|
import { DataTypes } from '@etsoo/shared';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { NotificationReactCallProps } from '../notifier/Notifier';
|
|
4
5
|
import { CultureAction } from '../states/CultureState';
|
|
5
6
|
import { IStateProps } from '../states/IState';
|
|
6
7
|
import { IPageData, PageAction } from '../states/PageState';
|
|
@@ -18,16 +19,31 @@ export declare function ReactAppStateDetector(props: IStateProps): React.Functio
|
|
|
18
19
|
/**
|
|
19
20
|
* Core application interface
|
|
20
21
|
*/
|
|
21
|
-
export interface IReactApp<S extends IAppSettings, D extends IUser, P extends IPageData> extends ICoreApp<S, React.ReactNode> {
|
|
22
|
+
export interface IReactApp<S extends IAppSettings, D extends IUser, P extends IPageData> extends ICoreApp<S, React.ReactNode, NotificationReactCallProps> {
|
|
22
23
|
/**
|
|
23
24
|
* User state
|
|
24
25
|
*/
|
|
25
26
|
readonly userState: UserState<D>;
|
|
27
|
+
/**
|
|
28
|
+
* Set page data
|
|
29
|
+
* @param data Page data
|
|
30
|
+
*/
|
|
31
|
+
setPageData(data: P): void;
|
|
32
|
+
/**
|
|
33
|
+
* Set page title and data
|
|
34
|
+
* @param key Page title resource key
|
|
35
|
+
*/
|
|
36
|
+
setPageKey(key: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Set page title and data
|
|
39
|
+
* @param title Page title
|
|
40
|
+
*/
|
|
41
|
+
setPageTitle(title: string): void;
|
|
26
42
|
}
|
|
27
43
|
/**
|
|
28
44
|
* React application
|
|
29
45
|
*/
|
|
30
|
-
export declare abstract class ReactApp<S extends IAppSettings, D extends IUser, P extends IPageData> extends CoreApp<S, React.ReactNode> implements IReactApp<S, D, P> {
|
|
46
|
+
export declare abstract class ReactApp<S extends IAppSettings, D extends IUser, P extends IPageData> extends CoreApp<S, React.ReactNode, NotificationReactCallProps> implements IReactApp<S, D, P> {
|
|
31
47
|
/**
|
|
32
48
|
* User state
|
|
33
49
|
*/
|
|
@@ -90,7 +106,7 @@ export declare abstract class ReactApp<S extends IAppSettings, D extends IUser,
|
|
|
90
106
|
* Show input dialog
|
|
91
107
|
* @param props Props
|
|
92
108
|
*/
|
|
93
|
-
showInputDialog({ title, message,
|
|
109
|
+
showInputDialog({ title, message, callback, ...rest }: InputDialogProps): void;
|
|
94
110
|
/**
|
|
95
111
|
* User login extended
|
|
96
112
|
* @param user New user
|
package/lib/app/ReactApp.js
CHANGED
|
@@ -123,13 +123,8 @@ export class ReactApp extends CoreApp {
|
|
|
123
123
|
* Show input dialog
|
|
124
124
|
* @param props Props
|
|
125
125
|
*/
|
|
126
|
-
showInputDialog({ title, message,
|
|
127
|
-
|
|
128
|
-
okLabel,
|
|
129
|
-
cancelLabel,
|
|
130
|
-
inputs
|
|
131
|
-
};
|
|
132
|
-
this.notifier.prompt(message, callback, title, props);
|
|
126
|
+
showInputDialog({ title, message, callback, ...rest }) {
|
|
127
|
+
this.notifier.prompt(message, callback, title, rest);
|
|
133
128
|
}
|
|
134
129
|
/**
|
|
135
130
|
* User login extended
|
|
@@ -20,4 +20,4 @@ export declare type CountdownButtonProps = Omit<ButtonProps, 'endIcon' | 'disabl
|
|
|
20
20
|
* @param props Props
|
|
21
21
|
* @returns Button
|
|
22
22
|
*/
|
|
23
|
-
export declare const CountdownButton: React.ForwardRefExoticComponent<Pick<CountdownButtonProps, "children" | "form" | "slot" | "title" | "value" | "name" | "type" | "onScroll" | "id" | "hidden" | "color" | "size" | keyof import("@mui/material/OverridableComponent").CommonProps | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "key" | "href" | "disableFocusRipple" | "variant" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "disableElevation" | "
|
|
23
|
+
export declare const CountdownButton: React.ForwardRefExoticComponent<Pick<CountdownButtonProps, "children" | "form" | "slot" | "title" | "value" | "name" | "type" | "fullWidth" | "onScroll" | "id" | "hidden" | "color" | "size" | keyof import("@mui/material/OverridableComponent").CommonProps | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "key" | "href" | "disableFocusRipple" | "variant" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "disableElevation" | "startIcon" | "onAction"> & React.RefAttributes<HTMLButtonElement>>;
|
package/lib/mu/NotifierMU.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { INotificaseBase, NotificationAlign, NotificationRenderProps } from '@etsoo/notificationbase';
|
|
2
|
-
import { ClassNameMap } from '@mui/material';
|
|
3
2
|
import React from 'react';
|
|
4
|
-
import { INotificationReact, NotificationReact, NotifierReact } from '../notifier/Notifier';
|
|
3
|
+
import { INotificationReact, NotificationReact, NotificationReactCallProps, NotifierReact } from '../notifier/Notifier';
|
|
5
4
|
/**
|
|
6
5
|
* MU notification
|
|
7
6
|
*/
|
|
@@ -19,7 +18,7 @@ export declare class NotificationMU extends NotificationReact {
|
|
|
19
18
|
* @param className Style class name
|
|
20
19
|
* @param classes Style classes
|
|
21
20
|
*/
|
|
22
|
-
render(props: NotificationRenderProps, className: string
|
|
21
|
+
render(props: NotificationRenderProps, className: string): JSX.Element;
|
|
23
22
|
}
|
|
24
23
|
/**
|
|
25
24
|
* Antd notifier
|
|
@@ -38,11 +37,11 @@ export declare class NotifierMU extends NotifierReact {
|
|
|
38
37
|
* @param children Children
|
|
39
38
|
* @param options Other options
|
|
40
39
|
*/
|
|
41
|
-
protected createContainer: (align: NotificationAlign, children: React.ReactNode[]
|
|
40
|
+
protected createContainer: (align: NotificationAlign, children: React.ReactNode[]) => JSX.Element;
|
|
42
41
|
/**
|
|
43
42
|
* Add raw definition
|
|
44
43
|
* @param data Notification data definition
|
|
45
44
|
* @param modal Show as modal
|
|
46
45
|
*/
|
|
47
|
-
protected addRaw(data: INotificaseBase
|
|
46
|
+
protected addRaw(data: INotificaseBase<NotificationReactCallProps>, modal?: boolean): INotificationReact;
|
|
48
47
|
}
|
package/lib/mu/NotifierMU.js
CHANGED
|
@@ -33,8 +33,10 @@ export class NotificationMU extends NotificationReact {
|
|
|
33
33
|
this.dismiss();
|
|
34
34
|
}
|
|
35
35
|
// Create alert
|
|
36
|
-
createAlert(_props, className
|
|
36
|
+
createAlert(_props, className) {
|
|
37
|
+
var _a;
|
|
37
38
|
const labels = Labels.NotificationMU;
|
|
39
|
+
const { inputs, fullScreen, fullWidth = true, maxWidth } = (_a = this.inputProps) !== null && _a !== void 0 ? _a : {};
|
|
38
40
|
let title = this.title;
|
|
39
41
|
let icon;
|
|
40
42
|
if (this.type === NotificationMessageType.Success) {
|
|
@@ -53,28 +55,31 @@ export class NotificationMU extends NotificationReact {
|
|
|
53
55
|
icon = React.createElement(Error, { color: "error" });
|
|
54
56
|
title !== null && title !== void 0 ? title : (title = labels.alertTitle);
|
|
55
57
|
}
|
|
56
|
-
return (React.createElement(Dialog, { key: this.id, open: this.open, PaperComponent: DraggablePaperComponent, className: className },
|
|
57
|
-
React.createElement(IconDialogTitle, {
|
|
58
|
+
return (React.createElement(Dialog, { key: this.id, open: this.open, PaperComponent: DraggablePaperComponent, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen },
|
|
59
|
+
React.createElement(IconDialogTitle, { id: "draggable-dialog-title" },
|
|
58
60
|
icon,
|
|
59
61
|
React.createElement("span", { className: "dialogTitle" }, title)),
|
|
60
62
|
React.createElement(DialogContent, null,
|
|
61
|
-
React.createElement(DialogContentText, null, this.content)
|
|
63
|
+
React.createElement(DialogContentText, null, this.content),
|
|
64
|
+
inputs),
|
|
62
65
|
React.createElement(DialogActions, null,
|
|
63
66
|
React.createElement(LoadingButton, { color: "primary", onClick: async () => await this.returnValue(undefined), autoFocus: true }, labels.alertOK))));
|
|
64
67
|
}
|
|
65
68
|
// Create confirm
|
|
66
|
-
createConfirm(_props, className
|
|
67
|
-
var _a;
|
|
69
|
+
createConfirm(_props, className) {
|
|
70
|
+
var _a, _b;
|
|
68
71
|
const labels = Labels.NotificationMU;
|
|
69
72
|
const title = (_a = this.title) !== null && _a !== void 0 ? _a : labels.confirmTitle;
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
const { okLabel, cancelLabel, inputs, fullScreen, fullWidth = true, maxWidth } = (_b = this.inputProps) !== null && _b !== void 0 ? _b : {};
|
|
74
|
+
const noLabel = cancelLabel !== null && cancelLabel !== void 0 ? cancelLabel : labels.confirmNo;
|
|
75
|
+
const yesLabel = okLabel !== null && okLabel !== void 0 ? okLabel : labels.confirmYes;
|
|
76
|
+
return (React.createElement(Dialog, { key: this.id, open: this.open, PaperComponent: DraggablePaperComponent, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen },
|
|
77
|
+
React.createElement(IconDialogTitle, { id: "draggable-dialog-title" },
|
|
74
78
|
React.createElement(Help, { color: "action" }),
|
|
75
79
|
React.createElement("span", { className: "dialogTitle" }, title)),
|
|
76
80
|
React.createElement(DialogContent, null,
|
|
77
|
-
React.createElement(DialogContentText, null, this.content)
|
|
81
|
+
React.createElement(DialogContentText, null, this.content),
|
|
82
|
+
inputs),
|
|
78
83
|
React.createElement(DialogActions, null,
|
|
79
84
|
React.createElement(LoadingButton, { color: "secondary", onClick: async () => await this.returnValue(false) }, noLabel),
|
|
80
85
|
React.createElement(LoadingButton, { color: "primary", onClick: async () => await this.returnValue(true), autoFocus: true }, yesLabel))));
|
|
@@ -89,7 +94,7 @@ export class NotificationMU extends NotificationReact {
|
|
|
89
94
|
return 'info';
|
|
90
95
|
}
|
|
91
96
|
// Create message
|
|
92
|
-
createMessage(_props, className
|
|
97
|
+
createMessage(_props, className) {
|
|
93
98
|
if (!this.open)
|
|
94
99
|
return React.createElement(React.Fragment, { key: this.id });
|
|
95
100
|
const setupProps = {
|
|
@@ -105,11 +110,11 @@ export class NotificationMU extends NotificationReact {
|
|
|
105
110
|
this.content)));
|
|
106
111
|
}
|
|
107
112
|
// Create prompt
|
|
108
|
-
createPrompt(_props, className
|
|
109
|
-
var _a;
|
|
113
|
+
createPrompt(_props, className) {
|
|
114
|
+
var _a, _b;
|
|
110
115
|
const labels = Labels.NotificationMU;
|
|
111
116
|
const title = (_a = this.title) !== null && _a !== void 0 ? _a : labels.promptTitle;
|
|
112
|
-
const { cancelLabel = labels.promptCancel, okLabel = labels.promptOK, inputs, type, ...rest } = this.inputProps;
|
|
117
|
+
const { cancelLabel = labels.promptCancel, okLabel = labels.promptOK, inputs, type, fullScreen, fullWidth = true, maxWidth, ...rest } = (_b = this.inputProps) !== null && _b !== void 0 ? _b : {};
|
|
113
118
|
const handleSubmit = async (event) => {
|
|
114
119
|
// Result
|
|
115
120
|
let result = undefined;
|
|
@@ -163,21 +168,21 @@ export class NotificationMU extends NotificationReact {
|
|
|
163
168
|
let value = undefined;
|
|
164
169
|
if (inputs == null) {
|
|
165
170
|
if (type === 'switch') {
|
|
166
|
-
localInputs = (React.createElement(Switch, { inputRef: inputRef, ...rest, value: "true", autoFocus: true }));
|
|
171
|
+
localInputs = (React.createElement(Switch, { inputRef: inputRef, ...rest, value: "true", autoFocus: true, required: true }));
|
|
167
172
|
}
|
|
168
173
|
else if (type === 'slider') {
|
|
169
174
|
localInputs = React.createElement(Slider, { onChange: (_e, v) => (value = v) });
|
|
170
175
|
}
|
|
171
176
|
else {
|
|
172
|
-
localInputs = (React.createElement(TextField, { inputRef: inputRef, autoFocus: true, fullWidth: true, type: type, ...rest }));
|
|
177
|
+
localInputs = (React.createElement(TextField, { inputRef: inputRef, autoFocus: true, fullWidth: true, type: type, required: true, ...rest }));
|
|
173
178
|
}
|
|
174
179
|
}
|
|
175
180
|
else {
|
|
176
181
|
localInputs = inputs;
|
|
177
182
|
}
|
|
178
|
-
return (React.createElement(Dialog, { key: this.id, open: this.open, PaperComponent: DraggablePaperComponent, className: className },
|
|
183
|
+
return (React.createElement(Dialog, { key: this.id, open: this.open, PaperComponent: DraggablePaperComponent, className: className, fullWidth: fullWidth, maxWidth: maxWidth, fullScreen: fullScreen },
|
|
179
184
|
React.createElement("form", null,
|
|
180
|
-
React.createElement(IconDialogTitle, {
|
|
185
|
+
React.createElement(IconDialogTitle, { id: "draggable-dialog-title" },
|
|
181
186
|
React.createElement(Info, { color: "primary" }),
|
|
182
187
|
React.createElement("span", { className: "dialogTitle" }, title)),
|
|
183
188
|
React.createElement(DialogContent, null,
|
|
@@ -188,10 +193,13 @@ export class NotificationMU extends NotificationReact {
|
|
|
188
193
|
React.createElement(LoadingButton, { color: "primary", autoFocus: true, onClick: handleSubmit }, okLabel)))));
|
|
189
194
|
}
|
|
190
195
|
// Create loading
|
|
191
|
-
createLoading(_props, className
|
|
196
|
+
createLoading(_props, className) {
|
|
197
|
+
var _a;
|
|
192
198
|
// Properties
|
|
193
199
|
const setupProps = { color: 'primary' };
|
|
194
200
|
const labels = Labels.NotificationMU;
|
|
201
|
+
// Input props
|
|
202
|
+
const { maxWidth = 'xs' } = (_a = this.inputProps) !== null && _a !== void 0 ? _a : {};
|
|
195
203
|
// Content
|
|
196
204
|
let content = this.content;
|
|
197
205
|
if (content === '@')
|
|
@@ -209,7 +217,7 @@ export class NotificationMU extends NotificationReact {
|
|
|
209
217
|
}
|
|
210
218
|
} },
|
|
211
219
|
React.createElement(CircularProgress, { ...setupProps }),
|
|
212
|
-
content && React.createElement(Box, { maxWidth:
|
|
220
|
+
content && (React.createElement(Box, { maxWidth: maxWidth === false ? undefined : maxWidth }, content)))));
|
|
213
221
|
}
|
|
214
222
|
/**
|
|
215
223
|
* Render method
|
|
@@ -217,24 +225,24 @@ export class NotificationMU extends NotificationReact {
|
|
|
217
225
|
* @param className Style class name
|
|
218
226
|
* @param classes Style classes
|
|
219
227
|
*/
|
|
220
|
-
render(props, className
|
|
228
|
+
render(props, className) {
|
|
221
229
|
// Loading bar
|
|
222
230
|
if (this.type === NotificationType.Loading) {
|
|
223
|
-
return this.createLoading(props, className
|
|
231
|
+
return this.createLoading(props, className);
|
|
224
232
|
}
|
|
225
233
|
else if (this.type === NotificationType.Confirm) {
|
|
226
|
-
return this.createConfirm(props, className
|
|
234
|
+
return this.createConfirm(props, className);
|
|
227
235
|
}
|
|
228
236
|
else if (this.type === NotificationType.Prompt) {
|
|
229
|
-
return this.createPrompt(props, className
|
|
237
|
+
return this.createPrompt(props, className);
|
|
230
238
|
}
|
|
231
239
|
else if (this.type === NotificationType.Error ||
|
|
232
240
|
(this.modal && this.type in NotificationMessageType)) {
|
|
233
241
|
// Alert or modal message
|
|
234
|
-
return this.createAlert(props, className
|
|
242
|
+
return this.createAlert(props, className);
|
|
235
243
|
}
|
|
236
244
|
else {
|
|
237
|
-
return this.createMessage(props, className
|
|
245
|
+
return this.createMessage(props, className);
|
|
238
246
|
}
|
|
239
247
|
}
|
|
240
248
|
}
|
|
@@ -250,7 +258,7 @@ export class NotifierMU extends NotifierReact {
|
|
|
250
258
|
* @param children Children
|
|
251
259
|
* @param options Other options
|
|
252
260
|
*/
|
|
253
|
-
this.createContainer = (align, children
|
|
261
|
+
this.createContainer = (align, children) => {
|
|
254
262
|
// Each align group, class equal to something similar to 'align-topleft'
|
|
255
263
|
const alignText = NotificationAlign[align].toLowerCase();
|
|
256
264
|
let className = `align-${alignText}`;
|
package/lib/mu/TextFieldEx.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export declare const TextFieldEx: React.ForwardRefExoticComponent<(Pick<import("
|
|
|
48
48
|
* Show password button
|
|
49
49
|
*/
|
|
50
50
|
showPassword?: boolean | undefined;
|
|
51
|
-
}, "children" | "label" | "slot" | "select" | "style" | "title" | "value" | "name" | "type" | "
|
|
51
|
+
}, "children" | "label" | "slot" | "select" | "style" | "title" | "value" | "className" | "name" | "type" | "fullWidth" | "onScroll" | "id" | "rows" | "hidden" | "color" | "size" | "disabled" | "error" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "key" | "margin" | "variant" | "autoFocus" | "autoComplete" | "readOnly" | "required" | "onEnter" | "inputProps" | "inputRef" | "SelectProps" | "InputLabelProps" | "focused" | "hiddenLabel" | "InputProps" | "FormHelperTextProps" | "helperText" | "multiline" | "maxRows" | "minRows" | "showClear" | "showPassword"> | Pick<import("@mui/material").FilledTextFieldProps & {
|
|
52
52
|
/**
|
|
53
53
|
* On enter click
|
|
54
54
|
*/
|
|
@@ -65,7 +65,7 @@ export declare const TextFieldEx: React.ForwardRefExoticComponent<(Pick<import("
|
|
|
65
65
|
* Show password button
|
|
66
66
|
*/
|
|
67
67
|
showPassword?: boolean | undefined;
|
|
68
|
-
}, "children" | "label" | "slot" | "select" | "style" | "title" | "value" | "name" | "type" | "
|
|
68
|
+
}, "children" | "label" | "slot" | "select" | "style" | "title" | "value" | "className" | "name" | "type" | "fullWidth" | "onScroll" | "id" | "rows" | "hidden" | "color" | "size" | "disabled" | "error" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "key" | "margin" | "variant" | "autoFocus" | "autoComplete" | "readOnly" | "required" | "onEnter" | "inputProps" | "inputRef" | "SelectProps" | "InputLabelProps" | "focused" | "hiddenLabel" | "InputProps" | "FormHelperTextProps" | "helperText" | "multiline" | "maxRows" | "minRows" | "showClear" | "showPassword"> | Pick<import("@mui/material").OutlinedTextFieldProps & {
|
|
69
69
|
/**
|
|
70
70
|
* On enter click
|
|
71
71
|
*/
|
|
@@ -82,4 +82,4 @@ export declare const TextFieldEx: React.ForwardRefExoticComponent<(Pick<import("
|
|
|
82
82
|
* Show password button
|
|
83
83
|
*/
|
|
84
84
|
showPassword?: boolean | undefined;
|
|
85
|
-
}, "children" | "label" | "slot" | "select" | "style" | "title" | "value" | "name" | "type" | "
|
|
85
|
+
}, "children" | "label" | "slot" | "select" | "style" | "title" | "value" | "className" | "name" | "type" | "fullWidth" | "onScroll" | "id" | "rows" | "hidden" | "color" | "size" | "disabled" | "error" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "key" | "margin" | "variant" | "autoFocus" | "autoComplete" | "readOnly" | "required" | "onEnter" | "inputProps" | "inputRef" | "SelectProps" | "InputLabelProps" | "focused" | "hiddenLabel" | "InputProps" | "FormHelperTextProps" | "helperText" | "multiline" | "maxRows" | "minRows" | "showClear" | "showPassword">) & React.RefAttributes<TextFieldExMethods>>;
|
|
@@ -1,11 +1,45 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { INotification, INotifier, Notification, NotificationAlign, NotificationContainer, NotificationRenderProps } from '@etsoo/notificationbase';
|
|
2
|
+
import { INotification, INotifier, Notification, NotificationAlign, NotificationCallProps, NotificationContainer, NotificationRenderProps } from '@etsoo/notificationbase';
|
|
3
3
|
import { IAction } from '@etsoo/appscript';
|
|
4
4
|
import { IProviderProps } from '../states/IState';
|
|
5
|
+
import { Breakpoint } from '@mui/material';
|
|
6
|
+
/**
|
|
7
|
+
* React notification call props
|
|
8
|
+
*/
|
|
9
|
+
export interface NotificationReactCallProps extends NotificationCallProps {
|
|
10
|
+
/**
|
|
11
|
+
* Full width
|
|
12
|
+
*/
|
|
13
|
+
fullWidth?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Full screen
|
|
16
|
+
*/
|
|
17
|
+
fullScreen?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Inputs layout
|
|
20
|
+
*/
|
|
21
|
+
inputs?: React.ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Max width
|
|
24
|
+
*/
|
|
25
|
+
maxWidth?: Breakpoint | false;
|
|
26
|
+
/**
|
|
27
|
+
* OK label
|
|
28
|
+
*/
|
|
29
|
+
okLabel?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Cancel label
|
|
32
|
+
*/
|
|
33
|
+
cancelLabel?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Type
|
|
36
|
+
*/
|
|
37
|
+
type?: string;
|
|
38
|
+
}
|
|
5
39
|
/**
|
|
6
40
|
* React notification interface
|
|
7
41
|
*/
|
|
8
|
-
export interface INotificationReact extends INotification<React.ReactNode> {
|
|
42
|
+
export interface INotificationReact extends INotification<React.ReactNode, NotificationReactCallProps> {
|
|
9
43
|
}
|
|
10
44
|
/**
|
|
11
45
|
* Action to manage the notifier
|
|
@@ -23,7 +57,7 @@ interface INotifierAction extends IAction {
|
|
|
23
57
|
/**
|
|
24
58
|
* React notification
|
|
25
59
|
*/
|
|
26
|
-
export declare abstract class NotificationReact extends Notification<React.ReactNode> {
|
|
60
|
+
export declare abstract class NotificationReact extends Notification<React.ReactNode, NotificationReactCallProps> {
|
|
27
61
|
}
|
|
28
62
|
/**
|
|
29
63
|
* React notification render props
|
|
@@ -33,7 +67,7 @@ export interface NotificationReactRenderProps extends NotificationRenderProps, I
|
|
|
33
67
|
/**
|
|
34
68
|
* Notifier interface
|
|
35
69
|
*/
|
|
36
|
-
export interface INotifierReact extends INotifier<React.ReactNode> {
|
|
70
|
+
export interface INotifierReact extends INotifier<React.ReactNode, NotificationReactCallProps> {
|
|
37
71
|
/**
|
|
38
72
|
* Create state provider
|
|
39
73
|
* @param className Style class name
|
|
@@ -51,7 +85,7 @@ export interface INotifierOptions {
|
|
|
51
85
|
/**
|
|
52
86
|
* Notifier for React
|
|
53
87
|
*/
|
|
54
|
-
export declare abstract class NotifierReact extends NotificationContainer<React.ReactNode> implements INotifierReact {
|
|
88
|
+
export declare abstract class NotifierReact extends NotificationContainer<React.ReactNode, NotificationReactCallProps> implements INotifierReact {
|
|
55
89
|
private static _instance;
|
|
56
90
|
/**
|
|
57
91
|
* Singleton instance
|
|
@@ -76,13 +110,12 @@ export declare abstract class NotifierReact extends NotificationContainer<React.
|
|
|
76
110
|
* @param children Children
|
|
77
111
|
* @param options Other options
|
|
78
112
|
*/
|
|
79
|
-
protected abstract createContainer(align: NotificationAlign, children: React.ReactNode[]
|
|
113
|
+
protected abstract createContainer(align: NotificationAlign, children: React.ReactNode[]): React.ReactElement;
|
|
80
114
|
/**
|
|
81
115
|
* Create state provider
|
|
82
116
|
* @param className Style class name
|
|
83
|
-
* @param optionGenerator Options generator
|
|
84
117
|
* @returns Provider
|
|
85
118
|
*/
|
|
86
|
-
createProvider(className?: string
|
|
119
|
+
createProvider(className?: string): React.FunctionComponent<NotificationReactRenderProps>;
|
|
87
120
|
}
|
|
88
121
|
export {};
|
package/lib/notifier/Notifier.js
CHANGED
|
@@ -35,25 +35,22 @@ export class NotifierReact extends NotificationContainer {
|
|
|
35
35
|
/**
|
|
36
36
|
* Create state provider
|
|
37
37
|
* @param className Style class name
|
|
38
|
-
* @param optionGenerator Options generator
|
|
39
38
|
* @returns Provider
|
|
40
39
|
*/
|
|
41
|
-
createProvider(className
|
|
40
|
+
createProvider(className) {
|
|
42
41
|
// Custom creator
|
|
43
42
|
const creator = (state, update, props) => {
|
|
44
43
|
// Hold the current state update
|
|
45
44
|
this.stateUpdate = update;
|
|
46
|
-
// Options
|
|
47
|
-
const options = optionGenerator ? optionGenerator() : {};
|
|
48
45
|
// Aligns collection
|
|
49
46
|
const aligns = [];
|
|
50
47
|
for (const align in state) {
|
|
51
48
|
// Notifications under the align
|
|
52
49
|
const notifications = state[align];
|
|
53
50
|
// UI collections
|
|
54
|
-
const ui = notifications.map((notification) => notification.render(props, className + '-item'
|
|
51
|
+
const ui = notifications.map((notification) => notification.render(props, className + '-item'));
|
|
55
52
|
// Add to the collection
|
|
56
|
-
aligns.push(this.createContainer(Number(align), ui
|
|
53
|
+
aligns.push(this.createContainer(Number(align), ui));
|
|
57
54
|
}
|
|
58
55
|
// Generate the component
|
|
59
56
|
return React.createElement('div', { className }, aligns);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.15",
|
|
4
4
|
"description": "TypeScript ReactJs framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"@emotion/react": "^11.4.1",
|
|
45
45
|
"@emotion/style": "^0.8.0",
|
|
46
46
|
"@emotion/styled": "^11.3.0",
|
|
47
|
-
"@etsoo/appscript": "^1.1.
|
|
48
|
-
"@etsoo/notificationbase": "^1.0.
|
|
47
|
+
"@etsoo/appscript": "^1.1.3",
|
|
48
|
+
"@etsoo/notificationbase": "^1.0.79",
|
|
49
49
|
"@etsoo/shared": "^1.0.46",
|
|
50
50
|
"@mui/icons-material": "^5.0.1",
|
|
51
51
|
"@mui/material": "^5.0.2",
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { NotificationReturn } from '@etsoo/notificationbase';
|
|
2
|
+
import { NotificationReactCallProps } from '../notifier/Notifier';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Input dialog props
|
|
5
6
|
*/
|
|
6
|
-
export type InputDialogProps = {
|
|
7
|
+
export type InputDialogProps = NotificationReactCallProps & {
|
|
7
8
|
/**
|
|
8
9
|
* Title
|
|
9
10
|
*/
|
|
@@ -14,23 +15,8 @@ export type InputDialogProps = {
|
|
|
14
15
|
*/
|
|
15
16
|
message: string;
|
|
16
17
|
|
|
17
|
-
/**
|
|
18
|
-
* Inputs layout
|
|
19
|
-
*/
|
|
20
|
-
inputs: React.ReactNode;
|
|
21
|
-
|
|
22
18
|
/**
|
|
23
19
|
* Callback
|
|
24
20
|
*/
|
|
25
21
|
callback: NotificationReturn<HTMLFormElement>;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* OK label
|
|
29
|
-
*/
|
|
30
|
-
okLabel?: string;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Cancel label
|
|
34
|
-
*/
|
|
35
|
-
cancelLabel?: string;
|
|
36
22
|
};
|
package/src/app/ReactApp.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import { DataTypes } from '@etsoo/shared';
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import { NotifierPromptProps } from '../mu/NotifierPromptProps';
|
|
11
|
+
import { NotificationReactCallProps } from '../notifier/Notifier';
|
|
11
12
|
import { CultureAction } from '../states/CultureState';
|
|
12
13
|
import { IStateProps } from '../states/IState';
|
|
13
14
|
import { IPageData, PageAction, PageActionType } from '../states/PageState';
|
|
@@ -56,11 +57,29 @@ export interface IReactApp<
|
|
|
56
57
|
S extends IAppSettings,
|
|
57
58
|
D extends IUser,
|
|
58
59
|
P extends IPageData
|
|
59
|
-
> extends ICoreApp<S, React.ReactNode> {
|
|
60
|
+
> extends ICoreApp<S, React.ReactNode, NotificationReactCallProps> {
|
|
60
61
|
/**
|
|
61
62
|
* User state
|
|
62
63
|
*/
|
|
63
64
|
readonly userState: UserState<D>;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Set page data
|
|
68
|
+
* @param data Page data
|
|
69
|
+
*/
|
|
70
|
+
setPageData(data: P): void;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Set page title and data
|
|
74
|
+
* @param key Page title resource key
|
|
75
|
+
*/
|
|
76
|
+
setPageKey(key: string): void;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Set page title and data
|
|
80
|
+
* @param title Page title
|
|
81
|
+
*/
|
|
82
|
+
setPageTitle(title: string): void;
|
|
64
83
|
}
|
|
65
84
|
|
|
66
85
|
/**
|
|
@@ -71,7 +90,7 @@ export abstract class ReactApp<
|
|
|
71
90
|
D extends IUser,
|
|
72
91
|
P extends IPageData
|
|
73
92
|
>
|
|
74
|
-
extends CoreApp<S, React.ReactNode>
|
|
93
|
+
extends CoreApp<S, React.ReactNode, NotificationReactCallProps>
|
|
75
94
|
implements IReactApp<S, D, P>
|
|
76
95
|
{
|
|
77
96
|
/**
|
|
@@ -190,17 +209,10 @@ export abstract class ReactApp<
|
|
|
190
209
|
showInputDialog({
|
|
191
210
|
title,
|
|
192
211
|
message,
|
|
193
|
-
inputs,
|
|
194
212
|
callback,
|
|
195
|
-
|
|
196
|
-
okLabel
|
|
213
|
+
...rest
|
|
197
214
|
}: InputDialogProps): void {
|
|
198
|
-
|
|
199
|
-
okLabel,
|
|
200
|
-
cancelLabel,
|
|
201
|
-
inputs
|
|
202
|
-
};
|
|
203
|
-
this.notifier.prompt<HTMLFormElement>(message, callback, title, props);
|
|
215
|
+
this.notifier.prompt<HTMLFormElement>(message, callback, title, rest);
|
|
204
216
|
}
|
|
205
217
|
|
|
206
218
|
/**
|
package/src/mu/NotifierMU.tsx
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
Button,
|
|
17
17
|
CircularProgress,
|
|
18
18
|
CircularProgressProps,
|
|
19
|
-
ClassNameMap,
|
|
20
19
|
Dialog,
|
|
21
20
|
DialogActions,
|
|
22
21
|
DialogContent,
|
|
@@ -35,10 +34,10 @@ import { Labels } from '../app/Labels';
|
|
|
35
34
|
import {
|
|
36
35
|
INotificationReact,
|
|
37
36
|
NotificationReact,
|
|
37
|
+
NotificationReactCallProps,
|
|
38
38
|
NotifierReact
|
|
39
39
|
} from '../notifier/Notifier';
|
|
40
40
|
import { DraggablePaperComponent } from './DraggablePaperComponent';
|
|
41
|
-
import { NotifierPromptProps } from './NotifierPromptProps';
|
|
42
41
|
import { LoadingButton } from './LoadingButton';
|
|
43
42
|
|
|
44
43
|
// Custom icon dialog title bar
|
|
@@ -69,13 +68,16 @@ export class NotificationMU extends NotificationReact {
|
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
// Create alert
|
|
72
|
-
private createAlert(
|
|
73
|
-
_props: NotificationRenderProps,
|
|
74
|
-
className: string,
|
|
75
|
-
classes: ClassNameMap<string>
|
|
76
|
-
) {
|
|
71
|
+
private createAlert(_props: NotificationRenderProps, className: string) {
|
|
77
72
|
const labels = Labels.NotificationMU;
|
|
78
73
|
|
|
74
|
+
const {
|
|
75
|
+
inputs,
|
|
76
|
+
fullScreen,
|
|
77
|
+
fullWidth = true,
|
|
78
|
+
maxWidth
|
|
79
|
+
} = this.inputProps ?? {};
|
|
80
|
+
|
|
79
81
|
let title = this.title;
|
|
80
82
|
let icon: React.ReactNode;
|
|
81
83
|
if (this.type === NotificationMessageType.Success) {
|
|
@@ -98,16 +100,17 @@ export class NotificationMU extends NotificationReact {
|
|
|
98
100
|
open={this.open}
|
|
99
101
|
PaperComponent={DraggablePaperComponent}
|
|
100
102
|
className={className}
|
|
103
|
+
fullWidth={fullWidth}
|
|
104
|
+
maxWidth={maxWidth}
|
|
105
|
+
fullScreen={fullScreen}
|
|
101
106
|
>
|
|
102
|
-
<IconDialogTitle
|
|
103
|
-
className={classes.iconTitle}
|
|
104
|
-
id="draggable-dialog-title"
|
|
105
|
-
>
|
|
107
|
+
<IconDialogTitle id="draggable-dialog-title">
|
|
106
108
|
{icon}
|
|
107
109
|
<span className="dialogTitle">{title}</span>
|
|
108
110
|
</IconDialogTitle>
|
|
109
111
|
<DialogContent>
|
|
110
112
|
<DialogContentText>{this.content}</DialogContentText>
|
|
113
|
+
{inputs}
|
|
111
114
|
</DialogContent>
|
|
112
115
|
<DialogActions>
|
|
113
116
|
<LoadingButton
|
|
@@ -123,16 +126,21 @@ export class NotificationMU extends NotificationReact {
|
|
|
123
126
|
}
|
|
124
127
|
|
|
125
128
|
// Create confirm
|
|
126
|
-
private createConfirm(
|
|
127
|
-
_props: NotificationRenderProps,
|
|
128
|
-
className: string,
|
|
129
|
-
classes: ClassNameMap<string>
|
|
130
|
-
) {
|
|
129
|
+
private createConfirm(_props: NotificationRenderProps, className: string) {
|
|
131
130
|
const labels = Labels.NotificationMU;
|
|
132
131
|
const title = this.title ?? labels.confirmTitle;
|
|
133
132
|
|
|
134
|
-
const
|
|
135
|
-
|
|
133
|
+
const {
|
|
134
|
+
okLabel,
|
|
135
|
+
cancelLabel,
|
|
136
|
+
inputs,
|
|
137
|
+
fullScreen,
|
|
138
|
+
fullWidth = true,
|
|
139
|
+
maxWidth
|
|
140
|
+
} = this.inputProps ?? {};
|
|
141
|
+
|
|
142
|
+
const noLabel = cancelLabel ?? labels.confirmNo;
|
|
143
|
+
const yesLabel = okLabel ?? labels.confirmYes;
|
|
136
144
|
|
|
137
145
|
return (
|
|
138
146
|
<Dialog
|
|
@@ -140,16 +148,17 @@ export class NotificationMU extends NotificationReact {
|
|
|
140
148
|
open={this.open}
|
|
141
149
|
PaperComponent={DraggablePaperComponent}
|
|
142
150
|
className={className}
|
|
151
|
+
fullWidth={fullWidth}
|
|
152
|
+
maxWidth={maxWidth}
|
|
153
|
+
fullScreen={fullScreen}
|
|
143
154
|
>
|
|
144
|
-
<IconDialogTitle
|
|
145
|
-
className={classes.iconTitle}
|
|
146
|
-
id="draggable-dialog-title"
|
|
147
|
-
>
|
|
155
|
+
<IconDialogTitle id="draggable-dialog-title">
|
|
148
156
|
<Help color="action" />
|
|
149
157
|
<span className="dialogTitle">{title}</span>
|
|
150
158
|
</IconDialogTitle>
|
|
151
159
|
<DialogContent>
|
|
152
160
|
<DialogContentText>{this.content}</DialogContentText>
|
|
161
|
+
{inputs}
|
|
153
162
|
</DialogContent>
|
|
154
163
|
<DialogActions>
|
|
155
164
|
<LoadingButton
|
|
@@ -178,11 +187,7 @@ export class NotificationMU extends NotificationReact {
|
|
|
178
187
|
}
|
|
179
188
|
|
|
180
189
|
// Create message
|
|
181
|
-
private createMessage(
|
|
182
|
-
_props: NotificationRenderProps,
|
|
183
|
-
className: string,
|
|
184
|
-
_classes: ClassNameMap<string>
|
|
185
|
-
) {
|
|
190
|
+
private createMessage(_props: NotificationRenderProps, className: string) {
|
|
186
191
|
if (!this.open) return <React.Fragment key={this.id}></React.Fragment>;
|
|
187
192
|
|
|
188
193
|
const setupProps: AlertProps = {
|
|
@@ -208,11 +213,7 @@ export class NotificationMU extends NotificationReact {
|
|
|
208
213
|
}
|
|
209
214
|
|
|
210
215
|
// Create prompt
|
|
211
|
-
private createPrompt(
|
|
212
|
-
_props: NotificationRenderProps,
|
|
213
|
-
className: string,
|
|
214
|
-
classes: ClassNameMap<string>
|
|
215
|
-
) {
|
|
216
|
+
private createPrompt(_props: NotificationRenderProps, className: string) {
|
|
216
217
|
const labels = Labels.NotificationMU;
|
|
217
218
|
const title = this.title ?? labels.promptTitle;
|
|
218
219
|
|
|
@@ -221,8 +222,11 @@ export class NotificationMU extends NotificationReact {
|
|
|
221
222
|
okLabel = labels.promptOK,
|
|
222
223
|
inputs,
|
|
223
224
|
type,
|
|
225
|
+
fullScreen,
|
|
226
|
+
fullWidth = true,
|
|
227
|
+
maxWidth,
|
|
224
228
|
...rest
|
|
225
|
-
} = this.inputProps
|
|
229
|
+
} = this.inputProps ?? {};
|
|
226
230
|
|
|
227
231
|
const handleSubmit = async (
|
|
228
232
|
event: React.MouseEvent<HTMLButtonElement>
|
|
@@ -286,6 +290,7 @@ export class NotificationMU extends NotificationReact {
|
|
|
286
290
|
{...rest}
|
|
287
291
|
value="true"
|
|
288
292
|
autoFocus
|
|
293
|
+
required
|
|
289
294
|
/>
|
|
290
295
|
);
|
|
291
296
|
} else if (type === 'slider') {
|
|
@@ -297,6 +302,7 @@ export class NotificationMU extends NotificationReact {
|
|
|
297
302
|
autoFocus
|
|
298
303
|
fullWidth
|
|
299
304
|
type={type}
|
|
305
|
+
required
|
|
300
306
|
{...rest}
|
|
301
307
|
/>
|
|
302
308
|
);
|
|
@@ -311,12 +317,12 @@ export class NotificationMU extends NotificationReact {
|
|
|
311
317
|
open={this.open}
|
|
312
318
|
PaperComponent={DraggablePaperComponent}
|
|
313
319
|
className={className}
|
|
320
|
+
fullWidth={fullWidth}
|
|
321
|
+
maxWidth={maxWidth}
|
|
322
|
+
fullScreen={fullScreen}
|
|
314
323
|
>
|
|
315
324
|
<form>
|
|
316
|
-
<IconDialogTitle
|
|
317
|
-
className={classes.iconTitle}
|
|
318
|
-
id="draggable-dialog-title"
|
|
319
|
-
>
|
|
325
|
+
<IconDialogTitle id="draggable-dialog-title">
|
|
320
326
|
<Info color="primary" />
|
|
321
327
|
<span className="dialogTitle">{title}</span>
|
|
322
328
|
</IconDialogTitle>
|
|
@@ -345,16 +351,15 @@ export class NotificationMU extends NotificationReact {
|
|
|
345
351
|
}
|
|
346
352
|
|
|
347
353
|
// Create loading
|
|
348
|
-
private createLoading(
|
|
349
|
-
_props: NotificationRenderProps,
|
|
350
|
-
className: string,
|
|
351
|
-
_classes: ClassNameMap<string>
|
|
352
|
-
) {
|
|
354
|
+
private createLoading(_props: NotificationRenderProps, className: string) {
|
|
353
355
|
// Properties
|
|
354
356
|
const setupProps: CircularProgressProps = { color: 'primary' };
|
|
355
357
|
|
|
356
358
|
const labels = Labels.NotificationMU;
|
|
357
359
|
|
|
360
|
+
// Input props
|
|
361
|
+
const { maxWidth = 'xs' } = this.inputProps ?? {};
|
|
362
|
+
|
|
358
363
|
// Content
|
|
359
364
|
let content = this.content;
|
|
360
365
|
if (content === '@') content = labels.loading.toString();
|
|
@@ -384,7 +389,13 @@ export class NotificationMU extends NotificationReact {
|
|
|
384
389
|
}}
|
|
385
390
|
>
|
|
386
391
|
<CircularProgress {...setupProps} />
|
|
387
|
-
{content &&
|
|
392
|
+
{content && (
|
|
393
|
+
<Box
|
|
394
|
+
maxWidth={maxWidth === false ? undefined : maxWidth}
|
|
395
|
+
>
|
|
396
|
+
{content}
|
|
397
|
+
</Box>
|
|
398
|
+
)}
|
|
388
399
|
</Box>
|
|
389
400
|
</Backdrop>
|
|
390
401
|
);
|
|
@@ -396,26 +407,22 @@ export class NotificationMU extends NotificationReact {
|
|
|
396
407
|
* @param className Style class name
|
|
397
408
|
* @param classes Style classes
|
|
398
409
|
*/
|
|
399
|
-
render(
|
|
400
|
-
props: NotificationRenderProps,
|
|
401
|
-
className: string,
|
|
402
|
-
classes: ClassNameMap<string>
|
|
403
|
-
) {
|
|
410
|
+
render(props: NotificationRenderProps, className: string) {
|
|
404
411
|
// Loading bar
|
|
405
412
|
if (this.type === NotificationType.Loading) {
|
|
406
|
-
return this.createLoading(props, className
|
|
413
|
+
return this.createLoading(props, className);
|
|
407
414
|
} else if (this.type === NotificationType.Confirm) {
|
|
408
|
-
return this.createConfirm(props, className
|
|
415
|
+
return this.createConfirm(props, className);
|
|
409
416
|
} else if (this.type === NotificationType.Prompt) {
|
|
410
|
-
return this.createPrompt(props, className
|
|
417
|
+
return this.createPrompt(props, className);
|
|
411
418
|
} else if (
|
|
412
419
|
this.type === NotificationType.Error ||
|
|
413
420
|
(this.modal && this.type in NotificationMessageType)
|
|
414
421
|
) {
|
|
415
422
|
// Alert or modal message
|
|
416
|
-
return this.createAlert(props, className
|
|
423
|
+
return this.createAlert(props, className);
|
|
417
424
|
} else {
|
|
418
|
-
return this.createMessage(props, className
|
|
425
|
+
return this.createMessage(props, className);
|
|
419
426
|
}
|
|
420
427
|
}
|
|
421
428
|
}
|
|
@@ -499,8 +506,7 @@ export class NotifierMU extends NotifierReact {
|
|
|
499
506
|
*/
|
|
500
507
|
protected createContainer = (
|
|
501
508
|
align: NotificationAlign,
|
|
502
|
-
children: React.ReactNode[]
|
|
503
|
-
_options: ClassNameMap<string>
|
|
509
|
+
children: React.ReactNode[]
|
|
504
510
|
) => {
|
|
505
511
|
// Each align group, class equal to something similar to 'align-topleft'
|
|
506
512
|
const alignText = NotificationAlign[align].toLowerCase();
|
|
@@ -555,7 +561,7 @@ export class NotifierMU extends NotifierReact {
|
|
|
555
561
|
* @param modal Show as modal
|
|
556
562
|
*/
|
|
557
563
|
protected addRaw(
|
|
558
|
-
data: INotificaseBase
|
|
564
|
+
data: INotificaseBase<NotificationReactCallProps>,
|
|
559
565
|
modal?: boolean
|
|
560
566
|
): INotificationReact {
|
|
561
567
|
// Destruct
|
package/src/notifier/Notifier.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
INotifier,
|
|
5
5
|
Notification,
|
|
6
6
|
NotificationAlign,
|
|
7
|
+
NotificationCallProps,
|
|
7
8
|
NotificationContainer,
|
|
8
9
|
NotificationDictionary,
|
|
9
10
|
NotificationRenderProps
|
|
@@ -11,13 +12,59 @@ import {
|
|
|
11
12
|
import { IAction } from '@etsoo/appscript';
|
|
12
13
|
import { State } from '../states/State';
|
|
13
14
|
import { IProviderProps, IUpdate } from '../states/IState';
|
|
15
|
+
import { Breakpoint } from '@mui/material';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* React notification call props
|
|
19
|
+
*/
|
|
20
|
+
export interface NotificationReactCallProps extends NotificationCallProps {
|
|
21
|
+
/**
|
|
22
|
+
* Full width
|
|
23
|
+
*/
|
|
24
|
+
fullWidth?: boolean;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Full screen
|
|
28
|
+
*/
|
|
29
|
+
fullScreen?: boolean;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Inputs layout
|
|
33
|
+
*/
|
|
34
|
+
inputs?: React.ReactNode;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Max width
|
|
38
|
+
*/
|
|
39
|
+
maxWidth?: Breakpoint | false;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* OK label
|
|
43
|
+
*/
|
|
44
|
+
okLabel?: string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Cancel label
|
|
48
|
+
*/
|
|
49
|
+
cancelLabel?: string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Type
|
|
53
|
+
*/
|
|
54
|
+
type?: string;
|
|
55
|
+
}
|
|
14
56
|
|
|
15
57
|
/**
|
|
16
58
|
* React notification interface
|
|
17
59
|
*/
|
|
18
|
-
export interface INotificationReact
|
|
60
|
+
export interface INotificationReact
|
|
61
|
+
extends INotification<React.ReactNode, NotificationReactCallProps> {}
|
|
19
62
|
|
|
20
|
-
interface ReactNotifications
|
|
63
|
+
interface ReactNotifications
|
|
64
|
+
extends NotificationDictionary<
|
|
65
|
+
React.ReactNode,
|
|
66
|
+
NotificationReactCallProps
|
|
67
|
+
> {}
|
|
21
68
|
|
|
22
69
|
/**
|
|
23
70
|
* Action to manage the notifier
|
|
@@ -37,7 +84,10 @@ interface INotifierAction extends IAction {
|
|
|
37
84
|
/**
|
|
38
85
|
* React notification
|
|
39
86
|
*/
|
|
40
|
-
export abstract class NotificationReact extends Notification<
|
|
87
|
+
export abstract class NotificationReact extends Notification<
|
|
88
|
+
React.ReactNode,
|
|
89
|
+
NotificationReactCallProps
|
|
90
|
+
> {}
|
|
41
91
|
|
|
42
92
|
/**
|
|
43
93
|
* React notification render props
|
|
@@ -49,7 +99,8 @@ export interface NotificationReactRenderProps
|
|
|
49
99
|
/**
|
|
50
100
|
* Notifier interface
|
|
51
101
|
*/
|
|
52
|
-
export interface INotifierReact
|
|
102
|
+
export interface INotifierReact
|
|
103
|
+
extends INotifier<React.ReactNode, NotificationReactCallProps> {
|
|
53
104
|
/**
|
|
54
105
|
* Create state provider
|
|
55
106
|
* @param className Style class name
|
|
@@ -73,7 +124,7 @@ export interface INotifierOptions {
|
|
|
73
124
|
* Notifier for React
|
|
74
125
|
*/
|
|
75
126
|
export abstract class NotifierReact
|
|
76
|
-
extends NotificationContainer<React.ReactNode>
|
|
127
|
+
extends NotificationContainer<React.ReactNode, NotificationReactCallProps>
|
|
77
128
|
implements INotifierReact
|
|
78
129
|
{
|
|
79
130
|
// Instance
|
|
@@ -117,17 +168,15 @@ export abstract class NotifierReact
|
|
|
117
168
|
*/
|
|
118
169
|
protected abstract createContainer(
|
|
119
170
|
align: NotificationAlign,
|
|
120
|
-
children: React.ReactNode[]
|
|
121
|
-
options: any
|
|
171
|
+
children: React.ReactNode[]
|
|
122
172
|
): React.ReactElement;
|
|
123
173
|
|
|
124
174
|
/**
|
|
125
175
|
* Create state provider
|
|
126
176
|
* @param className Style class name
|
|
127
|
-
* @param optionGenerator Options generator
|
|
128
177
|
* @returns Provider
|
|
129
178
|
*/
|
|
130
|
-
createProvider(className?: string
|
|
179
|
+
createProvider(className?: string) {
|
|
131
180
|
// Custom creator
|
|
132
181
|
const creator = (
|
|
133
182
|
state: ReactNotifications,
|
|
@@ -137,9 +186,6 @@ export abstract class NotifierReact
|
|
|
137
186
|
// Hold the current state update
|
|
138
187
|
this.stateUpdate = update;
|
|
139
188
|
|
|
140
|
-
// Options
|
|
141
|
-
const options = optionGenerator ? optionGenerator() : {};
|
|
142
|
-
|
|
143
189
|
// Aligns collection
|
|
144
190
|
const aligns: React.ReactNode[] = [];
|
|
145
191
|
for (const align in state) {
|
|
@@ -148,11 +194,11 @@ export abstract class NotifierReact
|
|
|
148
194
|
|
|
149
195
|
// UI collections
|
|
150
196
|
const ui = notifications.map((notification) =>
|
|
151
|
-
notification.render(props, className + '-item'
|
|
197
|
+
notification.render(props, className + '-item')
|
|
152
198
|
);
|
|
153
199
|
|
|
154
200
|
// Add to the collection
|
|
155
|
-
aligns.push(this.createContainer(Number(align), ui
|
|
201
|
+
aligns.push(this.createContainer(Number(align), ui));
|
|
156
202
|
}
|
|
157
203
|
|
|
158
204
|
// Generate the component
|
|
@@ -162,7 +208,10 @@ export abstract class NotifierReact
|
|
|
162
208
|
// Create state
|
|
163
209
|
const { provider } = State.create(
|
|
164
210
|
(
|
|
165
|
-
state: NotificationDictionary<
|
|
211
|
+
state: NotificationDictionary<
|
|
212
|
+
React.ReactNode,
|
|
213
|
+
NotificationReactCallProps
|
|
214
|
+
>,
|
|
166
215
|
_action: INotifierAction
|
|
167
216
|
) => {
|
|
168
217
|
// Collection update is done with NotificationContainer
|
|
@@ -170,7 +219,10 @@ export abstract class NotifierReact
|
|
|
170
219
|
},
|
|
171
220
|
this.notifications,
|
|
172
221
|
{} as IUpdate<
|
|
173
|
-
NotificationDictionary<
|
|
222
|
+
NotificationDictionary<
|
|
223
|
+
React.ReactNode,
|
|
224
|
+
NotificationReactCallProps
|
|
225
|
+
>,
|
|
174
226
|
INotifierAction
|
|
175
227
|
>,
|
|
176
228
|
creator
|