mui-notifications 0.1.0
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 +674 -0
- package/README.md +47 -0
- package/dist/NotificationsContext.d.ts +7 -0
- package/dist/NotificationsProvider.d.ts +15 -0
- package/dist/main.d.ts +2 -0
- package/dist/mui-notifications.cjs.js +132 -0
- package/dist/mui-notifications.es.js +7472 -0
- package/dist/useNonNullableContext.d.ts +2 -0
- package/dist/useNotifications.d.ts +20 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# MUI Notifications
|
|
2
|
+
|
|
3
|
+
Application notifications component using Material UI. Imperative APIs to show and interact with application notifications.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Install
|
|
7
|
+
|
|
8
|
+
Make sure you have **@mui/material** in your project, then:
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
npm install mui-notifications
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Usage
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
Install the NotificationsProvider.
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { NotificationsProvider } from '@toolpad/core/useNotifications';
|
|
22
|
+
|
|
23
|
+
function App({ children }) {
|
|
24
|
+
return <NotificationsProvider>{children}</NotificationsProvider>;
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Now you can get acess to the notifications APIs through the **useNotifications** hook.
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { useNotifications } from '@toolpad/core/useNotifications';
|
|
32
|
+
|
|
33
|
+
function MyApp() {
|
|
34
|
+
const notifications = useNotifications();
|
|
35
|
+
// ...
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Basic notification
|
|
40
|
+
|
|
41
|
+
You can notify your users with a neutral message by calling notifications.show. To have the notification automatically hide, add the autoHideDuration option. This expresses the time in milliseconds after which to close the notification.
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
notifications.show('Consider yourself notified!', {
|
|
45
|
+
autoHideDuration: 3000,
|
|
46
|
+
});
|
|
47
|
+
```
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CloseNotification, ShowNotification } from './useNotifications';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export interface NotificationsContextValue {
|
|
4
|
+
show: ShowNotification;
|
|
5
|
+
close: CloseNotification;
|
|
6
|
+
}
|
|
7
|
+
export declare const NotificationsContext: React.Context<NotificationsContextValue | null>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SnackbarProps } from '@mui/material';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export interface NotificationsProviderSlotProps {
|
|
4
|
+
snackbar: SnackbarProps;
|
|
5
|
+
}
|
|
6
|
+
export interface NotificationsProviderSlots {
|
|
7
|
+
snackbar: React.ElementType;
|
|
8
|
+
}
|
|
9
|
+
export interface NotificationsProviderProps {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
slots?: Partial<NotificationsProviderSlots>;
|
|
12
|
+
slotProps?: Partial<NotificationsProviderSlotProps>;
|
|
13
|
+
}
|
|
14
|
+
declare function NotificationsProvider(props: NotificationsProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export { NotificationsProvider };
|
package/dist/main.d.ts
ADDED