@jhelom/react-mui-message-dialog 1.0.9 → 1.0.10

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 jhelom
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 jhelom
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,99 +1,99 @@
1
- # react-mui-message-dialog
2
-
3
- # Overview
4
-
5
- `react-mui-message-dialog` is a simple and flexible message dialog component library for React + MUI (Material-UI) environments.
6
-
7
- - Unified UI based on MUI's Dialog component
8
- - Promise-based API for easy alert, confirm, and error dialogs
9
- - Global dialog management via Context Provider
10
- - TypeScript support
11
-
12
- Ideal for business applications and admin dashboards where you need to display messages or confirmations to users.
13
-
14
- # Install
15
-
16
- ```bash
17
- npm i @jhelom/react-mui-message-dialog
18
- ```
19
-
20
- # Usage
21
-
22
- Wrap your application with `MessageDialogProvider` to enable global message dialog functionality. This provider manages the dialog state and allows you to use the `useMessageDialog` hook anywhere in your component tree.
23
-
24
- ```tsx
25
- import { MessageDialogProvider } from "@jhelom/react-mui-message-dialog";
26
-
27
- createRoot(document.getElementById("root")!).render(
28
- <StrictMode>
29
- <MessageDialogProvider>
30
- <App />
31
- </MessageDialogProvider>
32
- </StrictMode>
33
- );
34
- ```
35
-
36
- After wrapping your app with `MessageDialogProvider`, you can use the `useMessageDialog` hook in any component. This hook provides functions to show alert, confirm, and error dialogs as Promises, making it easy to handle user interactions asynchronously.
37
-
38
- ```tsx
39
- import { useMessageDialog } from "@jhelom/react-mui-message-dialog";
40
-
41
- const messageDialog = useMessageDialog();
42
-
43
- // Show an alert dialog
44
- await messageDialog.alert("Alert Message");
45
-
46
- // Show a confirm dialog
47
- const result = await messageDialog.confirm("Confirm Message");
48
- if (result) {
49
- // OK
50
- } else {
51
- // Cancel
52
- }
53
-
54
- // Show an error dialog
55
- await messageDialog.error("Error Message");
56
- ```
57
-
58
- If a dialog API (`alert`, `confirm`, or `error`) is called again before the current dialog is closed, the previous pending Promise is resolved with `false`, and the latest call becomes active.
59
-
60
- ## Alert
61
-
62
- ![](docs/attached/alert.jpg)
63
-
64
- ## Confirm
65
-
66
- ![](docs/attached/confirm.jpg)
67
-
68
- ## Error
69
-
70
- ![](docs/attached/error.jpg)
71
-
72
- # Localize Text
73
-
74
- You can localize the dialog texts (button labels and titles) by passing a `MessageDialogSettings` object to the `settings` prop of `MessageDialogProvider`. Set each property to the desired language string to customize the dialog UI for your users.
75
-
76
- ```tsx
77
- import {
78
- MessageDialogProvider,
79
- MessageDialogSettings,
80
- } from "@jhelom/react-mui-message-dialog";
81
-
82
- const messageDialogSettings = {
83
- okText: "OK",
84
- cancelText: "Cancel",
85
- alertTitle: "Alert",
86
- confirmTitle: "Confirm",
87
- errorTitle: "Error",
88
- closeButtonAriaLabel: "Close dialog",
89
- titleHeight: 40,
90
- } as MessageDialogSettings;
91
-
92
- createRoot(document.getElementById("root")!).render(
93
- <StrictMode>
94
- <MessageDialogProvider settings={messageDialogSettings}>
95
- <App />
96
- </MessageDialogProvider>
97
- </StrictMode>
98
- );
99
- ```
1
+ # react-mui-message-dialog
2
+
3
+ # Overview
4
+
5
+ `react-mui-message-dialog` is a simple and flexible message dialog component library for React + MUI (Material-UI) environments.
6
+
7
+ - Unified UI based on MUI's Dialog component
8
+ - Promise-based API for easy alert, confirm, and error dialogs
9
+ - Global dialog management via Context Provider
10
+ - TypeScript support
11
+
12
+ Ideal for business applications and admin dashboards where you need to display messages or confirmations to users.
13
+
14
+ # Install
15
+
16
+ ```bash
17
+ npm i @jhelom/react-mui-message-dialog
18
+ ```
19
+
20
+ # Usage
21
+
22
+ Wrap your application with `MessageDialogProvider` to enable global message dialog functionality. This provider manages the dialog state and allows you to use the `useMessageDialog` hook anywhere in your component tree.
23
+
24
+ ```tsx
25
+ import { MessageDialogProvider } from "@jhelom/react-mui-message-dialog";
26
+
27
+ createRoot(document.getElementById("root")!).render(
28
+ <StrictMode>
29
+ <MessageDialogProvider>
30
+ <App />
31
+ </MessageDialogProvider>
32
+ </StrictMode>
33
+ );
34
+ ```
35
+
36
+ After wrapping your app with `MessageDialogProvider`, you can use the `useMessageDialog` hook in any component. This hook provides functions to show alert, confirm, and error dialogs as Promises, making it easy to handle user interactions asynchronously.
37
+
38
+ ```tsx
39
+ import { useMessageDialog } from "@jhelom/react-mui-message-dialog";
40
+
41
+ const messageDialog = useMessageDialog();
42
+
43
+ // Show an alert dialog
44
+ await messageDialog.alert("Alert Message");
45
+
46
+ // Show a confirm dialog
47
+ const result = await messageDialog.confirm("Confirm Message");
48
+ if (result) {
49
+ // OK
50
+ } else {
51
+ // Cancel
52
+ }
53
+
54
+ // Show an error dialog
55
+ await messageDialog.error("Error Message");
56
+ ```
57
+
58
+ If a dialog API (`alert`, `confirm`, or `error`) is called again before the current dialog is closed, the previous pending Promise is resolved with `false`, and the latest call becomes active.
59
+
60
+ ## Alert
61
+
62
+ ![](docs/attached/alert.jpg)
63
+
64
+ ## Confirm
65
+
66
+ ![](docs/attached/confirm.jpg)
67
+
68
+ ## Error
69
+
70
+ ![](docs/attached/error.jpg)
71
+
72
+ # Localize Text
73
+
74
+ You can localize the dialog texts (button labels and titles) by passing a `MessageDialogSettings` object to the `settings` prop of `MessageDialogProvider`. Set each property to the desired language string to customize the dialog UI for your users.
75
+
76
+ ```tsx
77
+ import {
78
+ MessageDialogProvider,
79
+ MessageDialogSettings,
80
+ } from "@jhelom/react-mui-message-dialog";
81
+
82
+ const messageDialogSettings = {
83
+ okText: "OK",
84
+ cancelText: "Cancel",
85
+ alertTitle: "Alert",
86
+ confirmTitle: "Confirm",
87
+ errorTitle: "Error",
88
+ closeButtonAriaLabel: "Close dialog",
89
+ titleHeight: 40,
90
+ } as MessageDialogSettings;
91
+
92
+ createRoot(document.getElementById("root")!).render(
93
+ <StrictMode>
94
+ <MessageDialogProvider settings={messageDialogSettings}>
95
+ <App />
96
+ </MessageDialogProvider>
97
+ </StrictMode>
98
+ );
99
+ ```