@kwiz/fluentui 1.0.173 → 1.0.174
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.
|
@@ -1,4 +1,38 @@
|
|
|
1
|
-
import { ToastIntent } from "@fluentui/react-components";
|
|
1
|
+
import { ToastId, ToastIntent, ToastPoliteness, ToastPosition } from "@fluentui/react-components";
|
|
2
|
+
export type toastOptionsType = {
|
|
3
|
+
/**
|
|
4
|
+
* Uniquely identifies a toast, used for update and dismiss operations
|
|
5
|
+
*/
|
|
6
|
+
toastId: ToastId;
|
|
7
|
+
/**
|
|
8
|
+
* The position the toast should render to
|
|
9
|
+
*/
|
|
10
|
+
position?: ToastPosition;
|
|
11
|
+
/**
|
|
12
|
+
* Auto dismiss timeout in milliseconds
|
|
13
|
+
* @default 3000
|
|
14
|
+
*/
|
|
15
|
+
timeout?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Toast timeout pauses while focus is on another window
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
pauseOnWindowBlur?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Toast timeout pauses while user cursor is on the toast
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
pauseOnHover?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Higher priority toasts will be rendered before lower priority toasts
|
|
28
|
+
*/
|
|
29
|
+
priority?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Used to determine [aria-live](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) narration
|
|
32
|
+
* This will override the intent prop
|
|
33
|
+
*/
|
|
34
|
+
politeness?: ToastPoliteness;
|
|
35
|
+
};
|
|
2
36
|
export type toastDispatcherType = (info: {
|
|
3
37
|
title?: string;
|
|
4
38
|
body?: string;
|
|
@@ -15,8 +49,11 @@ export type toastDispatcherType = (info: {
|
|
|
15
49
|
intent?: ToastIntent | "progress";
|
|
16
50
|
media?: JSX.Element;
|
|
17
51
|
inverted?: boolean;
|
|
18
|
-
}) => void;
|
|
52
|
+
} & Partial<toastOptionsType>) => void;
|
|
19
53
|
export declare function useToast(): {
|
|
20
54
|
control: JSX.Element;
|
|
21
55
|
dispatch: toastDispatcherType;
|
|
56
|
+
dismiss: (toastId: ToastId) => void;
|
|
57
|
+
dismissAll: () => void;
|
|
58
|
+
update: (info: toastOptionsType) => void;
|
|
22
59
|
};
|
|
@@ -5,21 +5,22 @@ import { useKWIZFluentContext } from "./context-internal";
|
|
|
5
5
|
export function useToast() {
|
|
6
6
|
const ctx = useKWIZFluentContext();
|
|
7
7
|
const toasterId = useId("toaster");
|
|
8
|
-
const { dispatchToast } = useToastController(toasterId);
|
|
8
|
+
const { dispatchToast, dismissToast, dismissAllToasts, updateToast } = useToastController(toasterId);
|
|
9
9
|
return {
|
|
10
10
|
control: _jsx(Toaster, { mountNode: ctx.mountNode, toasterId: toasterId }),
|
|
11
|
-
dispatch: info => {
|
|
11
|
+
dispatch: (info) => {
|
|
12
12
|
dispatchToast(_jsxs(Toast, { appearance: info.inverted ? "inverted" : undefined, children: [info.title && _jsx(ToastTitle, { media: info.media
|
|
13
13
|
? info.media
|
|
14
14
|
: info.intent === "progress"
|
|
15
15
|
? _jsx(Spinner, { size: "tiny" })
|
|
16
16
|
: undefined, action: info.titleAction ? _jsx(Link, { onClick: info.titleAction.onClick, children: info.titleAction.text }) : undefined, children: info.title }), info.body && _jsx(ToastBody, { subtitle: info.subtitle, children: info.body }), isNotEmptyArray(info.footerActions) &&
|
|
17
|
-
_jsx(ToastFooter, { children: info.footerActions.map((a, i) => _jsx(Link, { onClick: a.onClick, children: a.text }, `l${i}`)) })] }), {
|
|
18
|
-
intent: info.intent === "progress"
|
|
17
|
+
_jsx(ToastFooter, { children: info.footerActions.map((a, i) => _jsx(Link, { onClick: a.onClick, children: a.text }, `l${i}`)) })] }), Object.assign(Object.assign({}, (info || {})), { intent: info.intent === "progress"
|
|
19
18
|
? "info"
|
|
20
|
-
: info.intent || "info"
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
: info.intent || "info" }));
|
|
20
|
+
},
|
|
21
|
+
dismiss: dismissToast,
|
|
22
|
+
dismissAll: dismissAllToasts,
|
|
23
|
+
update: info => updateToast(info)
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
26
|
//# sourceMappingURL=use-toast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-toast.js","sourceRoot":"","sources":["../../src/helpers/use-toast.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"use-toast.js","sourceRoot":"","sources":["../../src/helpers/use-toast.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAwD,UAAU,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChM,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAiD1D,MAAM,UAAU,QAAQ;IAOpB,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IACnC,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACrG,OAAO;QACH,OAAO,EAAE,KAAC,OAAO,IAAC,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,GAAI;QACpE,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;YACf,aAAa,CAAC,MAAC,KAAK,IAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,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