@terreno/ui 0.0.16 → 0.0.18
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/dist/Button.js +7 -9
- package/dist/Button.js.map +1 -1
- package/dist/Common.d.ts +39 -0
- package/dist/TerrenoProvider.js +1 -1
- package/dist/TerrenoProvider.js.map +1 -1
- package/dist/Toast.js +2 -3
- package/dist/Toast.js.map +1 -1
- package/dist/ToastNotifications.d.ts +144 -0
- package/dist/ToastNotifications.js +387 -0
- package/dist/ToastNotifications.js.map +1 -0
- package/dist/UserInactivity.d.ts +28 -0
- package/dist/UserInactivity.js +100 -0
- package/dist/UserInactivity.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
- package/src/Button.tsx +20 -37
- package/src/Common.ts +45 -0
- package/src/DateTimeActionSheet.test.tsx +53 -4
- package/src/MobileAddressAutoComplete.test.tsx +47 -4
- package/src/ModalSheet.test.tsx +37 -5
- package/src/PickerSelect.test.tsx +41 -5
- package/src/Signature.test.tsx +21 -4
- package/src/SignatureField.test.tsx +49 -5
- package/src/SplitPage.test.tsx +71 -4
- package/src/TerrenoProvider.tsx +1 -1
- package/src/Toast.tsx +2 -3
- package/src/ToastNotifications.test.tsx +645 -0
- package/src/ToastNotifications.tsx +746 -0
- package/src/UnifiedAddressAutoComplete.test.tsx +43 -5
- package/src/UserInactivity.test.tsx +96 -0
- package/src/UserInactivity.tsx +129 -0
- package/src/WebAddressAutocomplete.test.tsx +22 -4
- package/src/__snapshots__/Button.test.tsx.snap +0 -347
- package/src/__snapshots__/DateTimeActionSheet.test.tsx.snap +11 -0
- package/src/__snapshots__/MobileAddressAutoComplete.test.tsx.snap +230 -0
- package/src/__snapshots__/ModalSheet.test.tsx.snap +37 -0
- package/src/__snapshots__/PickerSelect.test.tsx.snap +798 -11
- package/src/__snapshots__/Signature.test.tsx.snap +67 -0
- package/src/__snapshots__/SignatureField.test.tsx.snap +129 -21
- package/src/__snapshots__/SplitPage.test.tsx.snap +686 -0
- package/src/__snapshots__/UnifiedAddressAutoComplete.test.tsx.snap +377 -0
- package/src/__snapshots__/UserInactivity.test.tsx.snap +108 -0
- package/src/__snapshots__/WebAddressAutocomplete.test.tsx.snap +238 -0
- package/src/index.tsx +1 -0
package/dist/Button.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import FontAwesome6 from "@expo/vector-icons/FontAwesome6";
|
|
3
3
|
import debounce from "lodash/debounce";
|
|
4
|
-
import { useMemo, useState } from "react";
|
|
4
|
+
import { lazy, Suspense, useMemo, useState } from "react";
|
|
5
5
|
import { ActivityIndicator, Pressable, Text, View } from "react-native";
|
|
6
6
|
import { Box } from "./Box";
|
|
7
7
|
import { isMobileDevice } from "./MediaQuery";
|
|
8
|
-
import { Modal } from "./Modal";
|
|
9
8
|
import { useTheme } from "./Theme";
|
|
10
9
|
import { Tooltip } from "./Tooltip";
|
|
11
10
|
import { Unifier } from "./Unifier";
|
|
12
11
|
import { isNative } from "./Utilities";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
12
|
+
// Lazy load Modal to break the circular dependency: Modal -> Button -> Modal
|
|
13
|
+
const LazyModal = lazy(() => import("./Modal").then((module) => ({ default: module.Modal })));
|
|
16
14
|
const ButtonComponent = ({ confirmationText = "Are you sure you want to continue?", disabled = false, fullWidth = false, iconName, iconPosition = "left", loading: propsLoading, modalTitle = "Confirm", modalSubTitle, testID, text, variant = "primary", withConfirmation = false, onClick, }) => {
|
|
17
15
|
const [loading, setLoading] = useState(propsLoading);
|
|
18
16
|
const [showConfirmation, setShowConfirmation] = useState(false);
|
|
@@ -89,10 +87,10 @@ const ButtonComponent = ({ confirmationText = "Are you sure you want to continue
|
|
|
89
87
|
alignSelf: "center",
|
|
90
88
|
marginLeft: iconPosition === "right" ? 8 : 0,
|
|
91
89
|
marginRight: iconPosition === "left" ? 8 : 0,
|
|
92
|
-
}, children: _jsx(FontAwesome6, { color: color, name: iconName, size: 16, solid: true }) })), _jsx(Text, { style: { color, fontSize: 16, fontWeight: "700" }, children: text })] }), Boolean(loading) && (_jsx(Box, { marginLeft: 2, children: _jsx(ActivityIndicator, { color: color, size: "small" }) }))] }), withConfirmation && (_jsx(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
}, children: _jsx(FontAwesome6, { color: color, name: iconName, size: 16, solid: true }) })), _jsx(Text, { style: { color, fontSize: 16, fontWeight: "700" }, children: text })] }), Boolean(loading) && (_jsx(Box, { marginLeft: 2, children: _jsx(ActivityIndicator, { color: color, size: "small" }) }))] }), withConfirmation && showConfirmation && (_jsx(Suspense, { fallback: null, children: _jsx(LazyModal, { onDismiss: () => setShowConfirmation(false), primaryButtonOnClick: async () => {
|
|
91
|
+
await onClick();
|
|
92
|
+
setShowConfirmation(false);
|
|
93
|
+
}, primaryButtonText: "Confirm", secondaryButtonOnClick: () => setShowConfirmation(false), secondaryButtonText: "Cancel", subtitle: modalSubTitle, text: confirmationText, title: modalTitle, visible: showConfirmation }) }))] }));
|
|
96
94
|
};
|
|
97
95
|
export const Button = (props) => {
|
|
98
96
|
const { tooltipText, tooltipIdealPosition, tooltipIncludeArrow = false } = props;
|
package/dist/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,iCAAiC,CAAC;AAC3D,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAU,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,iCAAiC,CAAC;AAC3D,OAAO,QAAQ,MAAM,iBA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AS,EAC3B,sBAAsB,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,EACxD,mBAAmB,EAAC,QAAQ,EAC5B,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,gBAAgB,EACtB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,GACzB,GACO,CACZ,IACS,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAoB,CAAC,KAAK,EAAE,EAAE;IAC/C,MAAM,EAAC,WAAW,EAAE,oBAAoB,EAAE,mBAAmB,GAAG,KAAK,EAAC,GAAG,KAAK,CAAC;IAC/E,MAAM,gBAAgB,GAAG,cAAc,EAAE,IAAI,QAAQ,EAAE,CAAC;IAExD,IAAI,WAAW,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACrC,OAAO,CACL,KAAC,OAAO,IACN,aAAa,EAAE,oBAAoB,EACnC,YAAY,EAAE,mBAAmB,EACjC,IAAI,EAAE,WAAW,YAEjB,KAAC,eAAe,oBAAK,KAAK,EAAI,GACtB,CACX,CAAC;IACJ,CAAC;IAED,OAAO,KAAC,eAAe,oBAAK,KAAK,EAAI,CAAC;AACxC,CAAC,CAAC"}
|
package/dist/Common.d.ts
CHANGED
|
@@ -2322,4 +2322,43 @@ export interface SliderProps extends HelperTextProps, ErrorTextProps {
|
|
|
2322
2322
|
*/
|
|
2323
2323
|
valueMapping?: ValueMappingItem[];
|
|
2324
2324
|
}
|
|
2325
|
+
export interface UserInactivityProps {
|
|
2326
|
+
/**
|
|
2327
|
+
* Children components to embed inside UserInactivity's View.
|
|
2328
|
+
* If any children component is pressed, `onAction` is called after
|
|
2329
|
+
* `timeForInactivity` milliseconds.
|
|
2330
|
+
*/
|
|
2331
|
+
children: React.ReactNode;
|
|
2332
|
+
/**
|
|
2333
|
+
* If it's explicitly set to `true` after the component has already been initialized,
|
|
2334
|
+
* the timer restarts and the view is considered active until the new timer expires.
|
|
2335
|
+
* @default true
|
|
2336
|
+
*/
|
|
2337
|
+
isActive?: boolean;
|
|
2338
|
+
/**
|
|
2339
|
+
* Callback triggered anytime UserInactivity's View isn't touched for more than
|
|
2340
|
+
* `timeForInactivity` milliseconds.
|
|
2341
|
+
* The `active` argument is true if and only if the View wasn't touched for more
|
|
2342
|
+
* than `timeForInactivity` milliseconds.
|
|
2343
|
+
*/
|
|
2344
|
+
onAction: (active: boolean) => void;
|
|
2345
|
+
/**
|
|
2346
|
+
* If set to true, the timer is not reset when the keyboard appears
|
|
2347
|
+
* or disappears.
|
|
2348
|
+
* @default false
|
|
2349
|
+
*/
|
|
2350
|
+
skipKeyboard?: boolean;
|
|
2351
|
+
/**
|
|
2352
|
+
* Optional custom style for UserInactivity's View.
|
|
2353
|
+
* @default { flex: 1 }
|
|
2354
|
+
*/
|
|
2355
|
+
style?: StyleProp<ViewStyle>;
|
|
2356
|
+
/**
|
|
2357
|
+
* Number of milliseconds after which the view is considered inactive.
|
|
2358
|
+
* If it changed, the timer restarts and the view is considered active until
|
|
2359
|
+
* the new timer expires.
|
|
2360
|
+
* @default 10000
|
|
2361
|
+
*/
|
|
2362
|
+
timeForInactivity?: number;
|
|
2363
|
+
}
|
|
2325
2364
|
export {};
|
package/dist/TerrenoProvider.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Host } from "react-native-portalize";
|
|
3
|
-
import { ToastProvider } from "react-native-toast-notifications";
|
|
4
3
|
import { OpenAPIProvider } from "./OpenAPIContext";
|
|
5
4
|
import { ThemeProvider } from "./Theme";
|
|
6
5
|
import { Toast } from "./Toast";
|
|
6
|
+
import { ToastProvider } from "./ToastNotifications";
|
|
7
7
|
export const TerrenoProvider = ({ children, openAPISpecUrl }) => {
|
|
8
8
|
return (_jsx(ThemeProvider, { children: _jsx(ToastProvider, { animationDuration: 250, animationType: "slide-in", duration: 50000, offset: 50, placement: "bottom", renderToast: (toastOptions) => _jsx(Toast, Object.assign({}, toastOptions === null || toastOptions === void 0 ? void 0 : toastOptions.data)), swipeEnabled: true, children: _jsx(OpenAPIProvider, { specUrl: openAPISpecUrl, children: _jsx(Host, { children: children }) }) }) }));
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TerrenoProvider.js","sourceRoot":"","sources":["../src/TerrenoProvider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"TerrenoProvider.js","sourceRoot":"","sources":["../src/TerrenoProvider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAC;AAE5C,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AACtC,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAEnD,MAAM,CAAC,MAAM,eAAe,GAGvB,CAAC,EAAC,QAAQ,EAAE,cAAc,EAAC,EAAE,EAAE;IAClC,OAAO,CACL,KAAC,aAAa,cACZ,KAAC,aAAa,IACZ,iBAAiB,EAAE,GAAG,EACtB,aAAa,EAAC,UAAU,EACxB,QAAQ,EAAE,KAAK,EACf,MAAM,EAAE,EAAE,EACV,SAAS,EAAC,QAAQ,EAClB,WAAW,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC,KAAC,KAAK,oBAAK,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,EAAI,EAChE,YAAY,kBAEZ,KAAC,eAAe,IAAC,OAAO,EAAE,cAAc,YACtC,KAAC,IAAI,cAAE,QAAQ,GAAQ,GACP,GACJ,GACF,CACjB,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/Toast.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Platform, Pressable, View } from "react-native";
|
|
3
|
-
import { useToast as useRNToast } from "react-native-toast-notifications";
|
|
4
3
|
import { Heading } from "./Heading";
|
|
5
4
|
import { Icon } from "./Icon";
|
|
6
5
|
import { Text } from "./Text";
|
|
7
6
|
import { useTheme } from "./Theme";
|
|
7
|
+
import { useToastNotifications } from "./ToastNotifications";
|
|
8
8
|
import { isAPIError, printAPIError } from "./Utilities";
|
|
9
9
|
const TOAST_DURATION_MS = 3 * 1000;
|
|
10
10
|
export function useToast() {
|
|
11
|
-
const toast =
|
|
11
|
+
const toast = useToastNotifications();
|
|
12
12
|
const show = (title, options) => {
|
|
13
13
|
const toastData = Object.assign(Object.assign({ variant: "info" }, options), { title });
|
|
14
14
|
return toast.show(title, {
|
|
@@ -54,7 +54,6 @@ export function useToast() {
|
|
|
54
54
|
}
|
|
55
55
|
// TODO: Support secondary version of Toast.
|
|
56
56
|
// TODO: Support dismissible version of Toast. Currently only persistent are dismissible.
|
|
57
|
-
// This may require a different library from react-native-toast-notifications.
|
|
58
57
|
export const Toast = ({ title, variant = "info", secondary, size = "sm", onDismiss, persistent,
|
|
59
58
|
// TODO enforce these should only show if size is "lg" with type discrinimation
|
|
60
59
|
subtitle, }) => {
|
package/dist/Toast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.js","sourceRoot":"","sources":["../src/Toast.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Toast.js","sourceRoot":"","sources":["../src/Toast.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAGvD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,IAAI,EAAC,MAAM,QA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C,IAAI,QAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAC,IAAI,YACnC,KAAK,GACD,CACR,EACA,OAAO,CAAC,IAAI,KAAK,IAAI,IAAI,QAAQ,CAAC,IAAI,CACrC,KAAC,IAAI,IAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAC,IAAI,YAC9B,QAAQ,GACJ,CACR,IACI,IACF,EACN,OAAO,CAAC,UAAU,IAAI,SAAS,CAAC,IAAI,CACnC,KAAC,SAAS,iBACE,QAAQ,EAClB,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE;wBACL,UAAU,EAAE,QAAQ;wBACpB,SAAS,EAAE,QAAQ;wBACnB,OAAO,EAAE,MAAM;wBACf,GAAG,EAAE,EAAE;wBACP,UAAU,EAAE,EAAE;wBACd,OAAO,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;qBAC/B,YAED,KAAC,IAAI,IAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAC,OAAO,GAAG,GACjC,CACb,IACI,GACF,CACR,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored from react-native-toast-notifications v3.4.0
|
|
3
|
+
* https://github.com/arnnis/react-native-toast-notifications
|
|
4
|
+
*
|
|
5
|
+
* MIT License
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2020 Alireza Rezania
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
* SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
import React, { type FC, type ReactElement } from "react";
|
|
28
|
+
import { type StyleProp, type TextStyle, type ViewStyle } from "react-native";
|
|
29
|
+
export interface ToastOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Id is optional, you may provide an id only if you want to update toast later using toast.update()
|
|
32
|
+
*/
|
|
33
|
+
id?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Customize toast icon
|
|
36
|
+
*/
|
|
37
|
+
icon?: ReactElement;
|
|
38
|
+
/**
|
|
39
|
+
* Toast types, You can implement your custom types with JSX using renderType method on ToastContainer.
|
|
40
|
+
*/
|
|
41
|
+
type?: "normal" | "success" | "danger" | "warning" | string;
|
|
42
|
+
/**
|
|
43
|
+
* In ms, How long toast will stay before it go away
|
|
44
|
+
*/
|
|
45
|
+
duration?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Customize when toast should be placed
|
|
48
|
+
*/
|
|
49
|
+
placement?: "top" | "bottom" | "center";
|
|
50
|
+
/**
|
|
51
|
+
* Customize style of toast
|
|
52
|
+
*/
|
|
53
|
+
style?: StyleProp<ViewStyle>;
|
|
54
|
+
/**
|
|
55
|
+
* Customize style of toast text
|
|
56
|
+
*/
|
|
57
|
+
textStyle?: StyleProp<TextStyle>;
|
|
58
|
+
/**
|
|
59
|
+
* Customize how fast toast will show and hide
|
|
60
|
+
*/
|
|
61
|
+
animationDuration?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Customize how toast is animated when added or removed
|
|
64
|
+
*/
|
|
65
|
+
animationType?: "slide-in" | "zoom-in";
|
|
66
|
+
/**
|
|
67
|
+
* Customize success type icon
|
|
68
|
+
*/
|
|
69
|
+
successIcon?: ReactElement;
|
|
70
|
+
/**
|
|
71
|
+
* Customize danger type icon
|
|
72
|
+
*/
|
|
73
|
+
dangerIcon?: ReactElement;
|
|
74
|
+
/**
|
|
75
|
+
* Customize warning type icon
|
|
76
|
+
*/
|
|
77
|
+
warningIcon?: ReactElement;
|
|
78
|
+
/**
|
|
79
|
+
* Customize success type color. changes toast background color
|
|
80
|
+
*/
|
|
81
|
+
successColor?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Customize danger type color. changes toast background color
|
|
84
|
+
*/
|
|
85
|
+
dangerColor?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Customize warning type color. changes toast background color
|
|
88
|
+
*/
|
|
89
|
+
warningColor?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Customize normal type color. changes toast background color
|
|
92
|
+
*/
|
|
93
|
+
normalColor?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Register event for when toast is pressed. If you're using a custom toast you have to pass this to a Touchable.
|
|
96
|
+
*/
|
|
97
|
+
onPress?(id: string): void;
|
|
98
|
+
/**
|
|
99
|
+
* Execute event after toast is closed
|
|
100
|
+
*/
|
|
101
|
+
onClose?(): void;
|
|
102
|
+
/**
|
|
103
|
+
* Payload data for custom toasts. You can pass whatever you want
|
|
104
|
+
*/
|
|
105
|
+
data?: any;
|
|
106
|
+
swipeEnabled?: boolean;
|
|
107
|
+
}
|
|
108
|
+
export interface ToastProps extends ToastOptions {
|
|
109
|
+
id: string;
|
|
110
|
+
onDestroy(): void;
|
|
111
|
+
message: string | ReactElement;
|
|
112
|
+
open: boolean;
|
|
113
|
+
renderToast?(toast: ToastProps): ReactElement;
|
|
114
|
+
renderType?: {
|
|
115
|
+
[type: string]: (toast: ToastProps) => ReactElement;
|
|
116
|
+
};
|
|
117
|
+
onHide(): void;
|
|
118
|
+
}
|
|
119
|
+
export interface ToastContainerProps extends ToastOptions {
|
|
120
|
+
renderToast?(toast: ToastProps): ReactElement;
|
|
121
|
+
renderType?: {
|
|
122
|
+
[type: string]: (toast: ToastProps) => ReactElement;
|
|
123
|
+
};
|
|
124
|
+
offset?: number;
|
|
125
|
+
offsetTop?: number;
|
|
126
|
+
offsetBottom?: number;
|
|
127
|
+
swipeEnabled?: boolean;
|
|
128
|
+
}
|
|
129
|
+
export interface ToastContainerRef {
|
|
130
|
+
show: (message: string | ReactElement, toastOptions?: ToastOptions) => string;
|
|
131
|
+
update: (id: string, message: string | ReactElement, toastOptions?: ToastOptions) => void;
|
|
132
|
+
hide: (id: string) => void;
|
|
133
|
+
hideAll: () => void;
|
|
134
|
+
isOpen: (id: string) => boolean;
|
|
135
|
+
}
|
|
136
|
+
declare const ToastContainer: React.ForwardRefExoticComponent<ToastContainerProps & React.RefAttributes<ToastContainerRef>>;
|
|
137
|
+
export type ToastType = ToastContainerRef;
|
|
138
|
+
export declare let GlobalToast: ToastType;
|
|
139
|
+
type ToastProviderProps = ToastContainerProps & {
|
|
140
|
+
children: React.ReactNode;
|
|
141
|
+
};
|
|
142
|
+
export declare const ToastProvider: FC<ToastProviderProps>;
|
|
143
|
+
export declare const useToastNotifications: () => ToastType;
|
|
144
|
+
export default ToastContainer;
|