@impulse-ui-native/toast 0.0.0-stage → 6.0.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 +21 -0
- package/README.md +111 -2
- package/dist/components/index.d.mts +20 -0
- package/dist/components/index.js +7 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/toast-action.d.mts +10 -0
- package/dist/components/toast-action.js +64 -0
- package/dist/components/toast-action.js.map +1 -0
- package/dist/components/toast-close.d.mts +10 -0
- package/dist/components/toast-close.js +13 -0
- package/dist/components/toast-close.js.map +1 -0
- package/dist/components/toast-content.d.mts +10 -0
- package/dist/components/toast-content.js +27 -0
- package/dist/components/toast-content.js.map +1 -0
- package/dist/components/toast-description.d.mts +10 -0
- package/dist/components/toast-description.js +22 -0
- package/dist/components/toast-description.js.map +1 -0
- package/dist/components/toast-icon.d.mts +10 -0
- package/dist/components/toast-icon.js +33 -0
- package/dist/components/toast-icon.js.map +1 -0
- package/dist/components/toast-parts.d.mts +18 -0
- package/dist/components/toast-parts.js +20 -0
- package/dist/components/toast-parts.js.map +1 -0
- package/dist/components/toast-root.d.mts +10 -0
- package/dist/components/toast-root.js +84 -0
- package/dist/components/toast-root.js.map +1 -0
- package/dist/components/toast-title.d.mts +10 -0
- package/dist/components/toast-title.js +22 -0
- package/dist/components/toast-title.js.map +1 -0
- package/dist/components/toast.d.mts +10 -0
- package/dist/components/toast.js +48 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/constants/toast-icons.constants.d.mts +17 -0
- package/dist/constants/toast-icons.constants.js +14 -0
- package/dist/constants/toast-icons.constants.js.map +1 -0
- package/dist/constants/toast.constants.d.mts +5 -0
- package/dist/constants/toast.constants.js +9 -0
- package/dist/constants/toast.constants.js.map +1 -0
- package/dist/contexts/toast.context.d.mts +9 -0
- package/dist/contexts/toast.context.js +8 -0
- package/dist/contexts/toast.context.js.map +1 -0
- package/dist/hooks/use-toast-context.hook.d.mts +9 -0
- package/dist/hooks/use-toast-context.hook.js +13 -0
- package/dist/hooks/use-toast-context.hook.js.map +1 -0
- package/dist/hooks/use-toast-lifecycle.hook.d.mts +15 -0
- package/dist/hooks/use-toast-lifecycle.hook.js +129 -0
- package/dist/hooks/use-toast-lifecycle.hook.js.map +1 -0
- package/dist/hooks/use-toast-timer.hook.d.mts +3 -0
- package/dist/hooks/use-toast-timer.hook.js +50 -0
- package/dist/hooks/use-toast-timer.hook.js.map +1 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.mts +5 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/toast.types.d.mts +35 -0
- package/dist/types/toast.types.js +1 -0
- package/dist/types/toast.types.js.map +1 -0
- package/package.json +67 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ImpulseUI Native contributors
|
|
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,3 +1,112 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @impulse-ui-native/toast
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Native toast notifications built from theme tokens and the overlay lifecycle.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
`pnpm add @impulse-ui-native/toast`
|
|
8
|
+
|
|
9
|
+
Install the React, React Native, react-native-svg, react-native-safe-area-context, react-native-reanimated (4 or newer) and react-native-worklets peers. Configure Reanimated and Worklets in the native host. Place a ThemeProvider, SafeAreaProvider, OverlayProvider and OverlayHost at the application root, like Flyout. Keep OverlayHost outside scrolling content.
|
|
10
|
+
|
|
11
|
+
## Ready-made Toast and imperative opening
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import type { OverlayComponentProps } from "@impulse-ui-native/overlay";
|
|
15
|
+
import { OverlayStore } from "@impulse-ui-native/overlay";
|
|
16
|
+
import { Toast } from "@impulse-ui-native/toast";
|
|
17
|
+
|
|
18
|
+
export const overlays = new OverlayStore(); // Supply to OverlayProvider.
|
|
19
|
+
|
|
20
|
+
function SuccessToast(props: OverlayComponentProps) {
|
|
21
|
+
return <Toast {...props} tone="success" placement="bottom" duration={4000} />;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function SavedContent() {
|
|
25
|
+
return <Toast.Description>Your workspace is up to date.</Toast.Description>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Register once for a reusable singleton, like Flyout.
|
|
29
|
+
const saved = overlays.register({
|
|
30
|
+
id: "saved",
|
|
31
|
+
Component: SuccessToast,
|
|
32
|
+
Content: SavedContent,
|
|
33
|
+
title: "Changes saved",
|
|
34
|
+
});
|
|
35
|
+
saved.open();
|
|
36
|
+
saved.close();
|
|
37
|
+
|
|
38
|
+
// Register on each invocation to open independent notifications.
|
|
39
|
+
function notifySaved() {
|
|
40
|
+
return overlays
|
|
41
|
+
.register({
|
|
42
|
+
id: "saved",
|
|
43
|
+
Component: SuccessToast,
|
|
44
|
+
Content: SavedContent,
|
|
45
|
+
title: "Changes saved",
|
|
46
|
+
})
|
|
47
|
+
.open();
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Content props remain typed by `OverlayStore.register`, and `open` returns the overlay ID. Use `overlays.close(id)` to close an entry. A singleton controller ignores another open until its current entry has been removed after exit.
|
|
52
|
+
|
|
53
|
+
Like Input, `Toast` assembles its default UI from composable parts. It supplies the semantic icon and close icon, renders `title` and `description`, and places children inside `Toast.Content`. Pass `action` and `actionProps` to add an action; `actionProps` accepts `onPress`, `disabled`, `loading`, and `closeOnPress`. Use `hideIcon` or `hideClose` to omit those default parts.
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
<Toast
|
|
57
|
+
id="saved"
|
|
58
|
+
title="Changes saved"
|
|
59
|
+
description="Your workspace is up to date."
|
|
60
|
+
action="Undo"
|
|
61
|
+
actionProps={undoActionProps}
|
|
62
|
+
/>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Supply a stable `undoActionProps` object with your `onPress` handler.
|
|
66
|
+
|
|
67
|
+
## Custom composition
|
|
68
|
+
|
|
69
|
+
Composable parts render the children you supply. They do not create fallback icons or content. Use `Toast.Root` when you want to assemble the whole notification yourself:
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import { Icon } from "@impulse-ui-native/icon/components/icon";
|
|
73
|
+
import { XIcon } from "@impulse-ui-native/icon/icons/x";
|
|
74
|
+
|
|
75
|
+
<Toast.Root id="custom" duration={0}>
|
|
76
|
+
<Toast.Content>
|
|
77
|
+
<Toast.Title>Custom notification</Toast.Title>
|
|
78
|
+
<Toast.Description>Choose your own content and actions.</Toast.Description>
|
|
79
|
+
</Toast.Content>
|
|
80
|
+
<Toast.Close>
|
|
81
|
+
<Icon icon={XIcon} size={24} />
|
|
82
|
+
</Toast.Close>
|
|
83
|
+
</Toast.Root>;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Parts
|
|
87
|
+
|
|
88
|
+
- `Toast`: ready-made component with semantic icon, title/description, optional action, and close button.
|
|
89
|
+
- `Toast.Root`: overlay lifecycle and themed surface; renders only supplied children. Defaults: bottom placement, success tone, 4000 ms duration. The inherited overlay title is rendered by `Toast`, not Root.
|
|
90
|
+
- `Toast.Content`: flexible vertical text container.
|
|
91
|
+
- `Toast.Title` and `Toast.Description`: token-aware typography with native text props.
|
|
92
|
+
- `Toast.Icon`: themed semantic icon container; supply the icon as children.
|
|
93
|
+
- `Toast.Action`: runs onPress and dismisses by default; `closeOnPress={false}` keeps the toast open. Disabled and loading actions block presses.
|
|
94
|
+
- `Toast.Close`: dismiss action that renders supplied children, with an optional onPress callback.
|
|
95
|
+
|
|
96
|
+
## Overlay lifecycle
|
|
97
|
+
|
|
98
|
+
OverlayStore owns the entries and their open/close state. Toast adds no store, queue, or capacity limit. Each entry opens immediately at its placement, using the layer supplied by OverlayHost; newer entries at the same placement appear above older ones. There is no modal backdrop, so the surrounding application remains interactive.
|
|
99
|
+
|
|
100
|
+
The timer starts after entry animation finishes, pauses when the app leaves the active state, and resumes with the remaining time. `duration={0}` (or a non-finite/non-positive duration) persists until dismissal. Use a persistent duration for messages that require a response.
|
|
101
|
+
|
|
102
|
+
onOpen and onOpenFinished run during entry; onClose runs on dismissal, and onCloseFinished lets OverlayHost remove the entry after exit. Automatic dismissal calls the existing OverlayStore.close(id). Duration, foreground/background timer handling, and animation are component-owned. Unmounting cancels animation, timer and app-state subscriptions.
|
|
103
|
+
|
|
104
|
+
Toasts fade and translate by the theme edge offset. Top toasts sit 8 px below the top safe-area inset, using the toast topOffset token; bottom and side gaps use the 16 px edgeOffset token. Placements and IDs should remain stable for an entry's lifetime. Root is designed for imperative OverlayStore registration; use the returned controller to dismiss it.
|
|
105
|
+
|
|
106
|
+
## Theme
|
|
107
|
+
|
|
108
|
+
Toast uses `theme.components.toast` for surfaces, geometry, typography, actions and semantic icon colors. Override those tokens through ThemeProvider's components prop, including a factory that derives custom values from the active light/dark theme. No additional toast provider or host is needed.
|
|
109
|
+
|
|
110
|
+
## Verification
|
|
111
|
+
|
|
112
|
+
Run `pnpm --filter @impulse-ui-native/toast test` for Node checks of timer pause/resume and lifecycle cancellation. Native services and animation completion are mocked; use the Toast stories in the on-device Storybook host to verify rendering and touch interaction on iOS and Android.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { ToastProps, ToastRootProps, ToastContentProps, ToastTitleProps, ToastDescriptionProps, ToastIconProps, ToastActionProps, ToastCloseProps } from '../types/toast.types.mjs';
|
|
4
|
+
import '@impulse-ui-native/overlay';
|
|
5
|
+
import '@impulse-ui-native/primitives';
|
|
6
|
+
import '@impulse-ui-native/theme';
|
|
7
|
+
|
|
8
|
+
declare const Toast: react.NamedExoticComponent<ToastProps> & {
|
|
9
|
+
readonly type: ({ children, title, description, action, actionProps, tone, hideIcon, hideClose, ...props }: ToastProps) => react_jsx_runtime.JSX.Element;
|
|
10
|
+
} & {
|
|
11
|
+
Root: react.MemoExoticComponent<(props: ToastRootProps) => react_jsx_runtime.JSX.Element | null>;
|
|
12
|
+
Content: react.MemoExoticComponent<({ style, ...props }: ToastContentProps) => react_jsx_runtime.JSX.Element>;
|
|
13
|
+
Title: react.MemoExoticComponent<(props: ToastTitleProps) => react_jsx_runtime.JSX.Element>;
|
|
14
|
+
Description: react.MemoExoticComponent<(props: ToastDescriptionProps) => react_jsx_runtime.JSX.Element>;
|
|
15
|
+
Icon: react.MemoExoticComponent<({ children, style, ...props }: ToastIconProps) => react_jsx_runtime.JSX.Element>;
|
|
16
|
+
Action: react.MemoExoticComponent<({ children, closeOnPress, onPress, disabled, loading, style, ...props }: ToastActionProps) => react_jsx_runtime.JSX.Element>;
|
|
17
|
+
Close: react.MemoExoticComponent<({ children, ...props }: ToastCloseProps) => react_jsx_runtime.JSX.Element>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { Toast };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["import { ToastComponent } from \"./toast\";\nimport { Toast as ToastParts } from \"./toast-parts\";\n\nexport const Toast = Object.assign(ToastComponent, ToastParts);\n"],"mappings":"AAAA,SAAS,sBAAsB;AAC/B,SAAS,SAAS,kBAAkB;AAE7B,MAAM,QAAQ,OAAO,OAAO,gBAAgB,UAAU;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { ToastActionProps } from '../types/toast.types.mjs';
|
|
4
|
+
import '@impulse-ui-native/overlay';
|
|
5
|
+
import '@impulse-ui-native/primitives';
|
|
6
|
+
import '@impulse-ui-native/theme';
|
|
7
|
+
|
|
8
|
+
declare const ToastAction: react.MemoExoticComponent<({ children, closeOnPress, onPress, disabled, loading, style, ...props }: ToastActionProps) => react_jsx_runtime.JSX.Element>;
|
|
9
|
+
|
|
10
|
+
export { ToastAction };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useMemo } from "react";
|
|
3
|
+
import { StyleSheet } from "react-native";
|
|
4
|
+
import { useEventCallback } from "@impulse-ui-native/core";
|
|
5
|
+
import { Pressable, Typography } from "@impulse-ui-native/primitives";
|
|
6
|
+
import { useThemedStyles } from "@impulse-ui-native/theme";
|
|
7
|
+
import { useToastContext } from "../hooks/use-toast-context.hook";
|
|
8
|
+
const ToastAction = memo(function ToastAction2({
|
|
9
|
+
children,
|
|
10
|
+
closeOnPress = true,
|
|
11
|
+
onPress,
|
|
12
|
+
disabled,
|
|
13
|
+
loading,
|
|
14
|
+
style,
|
|
15
|
+
...props
|
|
16
|
+
}) {
|
|
17
|
+
const { interactive, close } = useToastContext();
|
|
18
|
+
const blocked = disabled === true || loading === true || !interactive;
|
|
19
|
+
const styles = useThemedStyles(themedStyles, { blocked }, [blocked]);
|
|
20
|
+
const actionStyle = useMemo(
|
|
21
|
+
() => [styles.action, style],
|
|
22
|
+
[styles.action, style]
|
|
23
|
+
);
|
|
24
|
+
const handlePress = useEventCallback((event) => {
|
|
25
|
+
if (blocked) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
onPress?.(event);
|
|
29
|
+
if (closeOnPress) {
|
|
30
|
+
close();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return /* @__PURE__ */ jsx(
|
|
34
|
+
Pressable,
|
|
35
|
+
{
|
|
36
|
+
hitSlop: styles.action.paddingHorizontal,
|
|
37
|
+
...props,
|
|
38
|
+
disabled: blocked,
|
|
39
|
+
onPress: handlePress,
|
|
40
|
+
style: actionStyle,
|
|
41
|
+
children: typeof children === "string" ? /* @__PURE__ */ jsx(Typography.Label, { style: styles.label, children }) : children
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
});
|
|
45
|
+
function themedStyles(theme, { blocked }) {
|
|
46
|
+
const tokens = theme.components.toast;
|
|
47
|
+
return StyleSheet.create({
|
|
48
|
+
action: {
|
|
49
|
+
minHeight: tokens.actionMinSize,
|
|
50
|
+
minWidth: tokens.actionMinSize,
|
|
51
|
+
alignItems: "center",
|
|
52
|
+
justifyContent: "center",
|
|
53
|
+
paddingHorizontal: tokens.gap
|
|
54
|
+
},
|
|
55
|
+
label: {
|
|
56
|
+
color: blocked ? tokens.disabledColor : tokens.actionColor,
|
|
57
|
+
fontWeight: "600"
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
ToastAction
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=toast-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/toast-action.tsx"],"sourcesContent":["import type { GestureResponderEvent } from \"react-native\";\nimport { memo, useMemo } from \"react\";\nimport { StyleSheet } from \"react-native\";\n\nimport type { AppTheme } from \"@impulse-ui-native/theme\";\nimport { useEventCallback } from \"@impulse-ui-native/core\";\nimport { Pressable, Typography } from \"@impulse-ui-native/primitives\";\nimport { useThemedStyles } from \"@impulse-ui-native/theme\";\n\nimport type { ToastActionProps } from \"../types\";\nimport { useToastContext } from \"../hooks/use-toast-context.hook\";\n\nexport const ToastAction = memo(function ToastAction({\n children,\n closeOnPress = true,\n onPress,\n disabled,\n loading,\n style,\n ...props\n}: ToastActionProps) {\n const { interactive, close } = useToastContext();\n\n const blocked = disabled === true || loading === true || !interactive;\n\n const styles = useThemedStyles(themedStyles, { blocked }, [blocked]);\n\n const actionStyle = useMemo(\n () => [styles.action, style],\n [styles.action, style],\n );\n\n const handlePress = useEventCallback((event: GestureResponderEvent) => {\n if (blocked) {\n return;\n }\n\n onPress?.(event);\n\n if (closeOnPress) {\n close();\n }\n });\n\n return (\n <Pressable\n hitSlop={styles.action.paddingHorizontal}\n {...props}\n disabled={blocked}\n onPress={handlePress}\n style={actionStyle}\n >\n {typeof children === \"string\" ? (\n <Typography.Label style={styles.label}>{children}</Typography.Label>\n ) : (\n children\n )}\n </Pressable>\n );\n});\n\nfunction themedStyles(\n theme: AppTheme,\n { blocked }: { blocked: boolean | undefined },\n) {\n const tokens = theme.components.toast;\n\n return StyleSheet.create({\n action: {\n minHeight: tokens.actionMinSize,\n minWidth: tokens.actionMinSize,\n alignItems: \"center\",\n justifyContent: \"center\",\n paddingHorizontal: tokens.gap,\n },\n label: {\n color: blocked ? tokens.disabledColor : tokens.actionColor,\n fontWeight: \"600\",\n },\n });\n}\n"],"mappings":"AAqDQ;AApDR,SAAS,MAAM,eAAe;AAC9B,SAAS,kBAAkB;AAG3B,SAAS,wBAAwB;AACjC,SAAS,WAAW,kBAAkB;AACtC,SAAS,uBAAuB;AAGhC,SAAS,uBAAuB;AAEzB,MAAM,cAAc,KAAK,SAASA,aAAY;AAAA,EACnD;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAqB;AACnB,QAAM,EAAE,aAAa,MAAM,IAAI,gBAAgB;AAE/C,QAAM,UAAU,aAAa,QAAQ,YAAY,QAAQ,CAAC;AAE1D,QAAM,SAAS,gBAAgB,cAAc,EAAE,QAAQ,GAAG,CAAC,OAAO,CAAC;AAEnE,QAAM,cAAc;AAAA,IAClB,MAAM,CAAC,OAAO,QAAQ,KAAK;AAAA,IAC3B,CAAC,OAAO,QAAQ,KAAK;AAAA,EACvB;AAEA,QAAM,cAAc,iBAAiB,CAAC,UAAiC;AACrE,QAAI,SAAS;AACX;AAAA,IACF;AAEA,cAAU,KAAK;AAEf,QAAI,cAAc;AAChB,YAAM;AAAA,IACR;AAAA,EACF,CAAC;AAED,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAS,OAAO,OAAO;AAAA,MACtB,GAAG;AAAA,MACJ,UAAU;AAAA,MACV,SAAS;AAAA,MACT,OAAO;AAAA,MAEN,iBAAO,aAAa,WACnB,oBAAC,WAAW,OAAX,EAAiB,OAAO,OAAO,OAAQ,UAAS,IAEjD;AAAA;AAAA,EAEJ;AAEJ,CAAC;AAED,SAAS,aACP,OACA,EAAE,QAAQ,GACV;AACA,QAAM,SAAS,MAAM,WAAW;AAEhC,SAAO,WAAW,OAAO;AAAA,IACvB,QAAQ;AAAA,MACN,WAAW,OAAO;AAAA,MAClB,UAAU,OAAO;AAAA,MACjB,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,mBAAmB,OAAO;AAAA,IAC5B;AAAA,IACA,OAAO;AAAA,MACL,OAAO,UAAU,OAAO,gBAAgB,OAAO;AAAA,MAC/C,YAAY;AAAA,IACd;AAAA,EACF,CAAC;AACH;","names":["ToastAction"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { ToastCloseProps } from '../types/toast.types.mjs';
|
|
4
|
+
import '@impulse-ui-native/overlay';
|
|
5
|
+
import '@impulse-ui-native/primitives';
|
|
6
|
+
import '@impulse-ui-native/theme';
|
|
7
|
+
|
|
8
|
+
declare const ToastClose: react.MemoExoticComponent<({ children, ...props }: ToastCloseProps) => react_jsx_runtime.JSX.Element>;
|
|
9
|
+
|
|
10
|
+
export { ToastClose };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { ToastAction } from "./toast-action";
|
|
4
|
+
const ToastClose = memo(function ToastClose2({
|
|
5
|
+
children,
|
|
6
|
+
...props
|
|
7
|
+
}) {
|
|
8
|
+
return /* @__PURE__ */ jsx(ToastAction, { ...props, closeOnPress: true, children });
|
|
9
|
+
});
|
|
10
|
+
export {
|
|
11
|
+
ToastClose
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=toast-close.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/toast-close.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport type { ToastCloseProps } from \"../types\";\nimport { ToastAction } from \"./toast-action\";\n\nexport const ToastClose = memo(function ToastClose({\n children,\n ...props\n}: ToastCloseProps) {\n return (\n <ToastAction {...props} closeOnPress>\n {children}\n </ToastAction>\n );\n});\n"],"mappings":"AAUI;AAVJ,SAAS,YAAY;AAGrB,SAAS,mBAAmB;AAErB,MAAM,aAAa,KAAK,SAASA,YAAW;AAAA,EACjD;AAAA,EACA,GAAG;AACL,GAAoB;AAClB,SACE,oBAAC,eAAa,GAAG,OAAO,cAAY,MACjC,UACH;AAEJ,CAAC;","names":["ToastClose"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { ToastContentProps } from '../types/toast.types.mjs';
|
|
4
|
+
import '@impulse-ui-native/overlay';
|
|
5
|
+
import '@impulse-ui-native/primitives';
|
|
6
|
+
import '@impulse-ui-native/theme';
|
|
7
|
+
|
|
8
|
+
declare const ToastContent: react.MemoExoticComponent<({ style, ...props }: ToastContentProps) => react_jsx_runtime.JSX.Element>;
|
|
9
|
+
|
|
10
|
+
export { ToastContent };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useMemo } from "react";
|
|
3
|
+
import { StyleSheet } from "react-native";
|
|
4
|
+
import { View } from "@impulse-ui-native/primitives";
|
|
5
|
+
import { useThemedStyles } from "@impulse-ui-native/theme";
|
|
6
|
+
import { useToastContext } from "../hooks/use-toast-context.hook";
|
|
7
|
+
const ToastContent = memo(function ToastContent2({
|
|
8
|
+
style,
|
|
9
|
+
...props
|
|
10
|
+
}) {
|
|
11
|
+
useToastContext();
|
|
12
|
+
const styles = useThemedStyles(themedStyles);
|
|
13
|
+
const contentStyle = useMemo(
|
|
14
|
+
() => [styles.content, style],
|
|
15
|
+
[styles.content, style]
|
|
16
|
+
);
|
|
17
|
+
return /* @__PURE__ */ jsx(View, { ...props, style: contentStyle });
|
|
18
|
+
});
|
|
19
|
+
function themedStyles(theme) {
|
|
20
|
+
return StyleSheet.create({
|
|
21
|
+
content: { flex: 1, minWidth: 0, gap: theme.components.toast.contentGap }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
ToastContent
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=toast-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/toast-content.tsx"],"sourcesContent":["import { memo, useMemo } from \"react\";\nimport { StyleSheet } from \"react-native\";\n\nimport type { AppTheme } from \"@impulse-ui-native/theme\";\nimport { View } from \"@impulse-ui-native/primitives\";\nimport { useThemedStyles } from \"@impulse-ui-native/theme\";\n\nimport type { ToastContentProps } from \"../types\";\nimport { useToastContext } from \"../hooks/use-toast-context.hook\";\n\nexport const ToastContent = memo(function ToastContent({\n style,\n ...props\n}: ToastContentProps) {\n useToastContext();\n\n const styles = useThemedStyles(themedStyles);\n\n const contentStyle = useMemo(\n () => [styles.content, style],\n [styles.content, style],\n );\n\n return <View {...props} style={contentStyle} />;\n});\n\nfunction themedStyles(theme: AppTheme) {\n return StyleSheet.create({\n content: { flex: 1, minWidth: 0, gap: theme.components.toast.contentGap },\n });\n}\n"],"mappings":"AAuBS;AAvBT,SAAS,MAAM,eAAe;AAC9B,SAAS,kBAAkB;AAG3B,SAAS,YAAY;AACrB,SAAS,uBAAuB;AAGhC,SAAS,uBAAuB;AAEzB,MAAM,eAAe,KAAK,SAASA,cAAa;AAAA,EACrD;AAAA,EACA,GAAG;AACL,GAAsB;AACpB,kBAAgB;AAEhB,QAAM,SAAS,gBAAgB,YAAY;AAE3C,QAAM,eAAe;AAAA,IACnB,MAAM,CAAC,OAAO,SAAS,KAAK;AAAA,IAC5B,CAAC,OAAO,SAAS,KAAK;AAAA,EACxB;AAEA,SAAO,oBAAC,QAAM,GAAG,OAAO,OAAO,cAAc;AAC/C,CAAC;AAED,SAAS,aAAa,OAAiB;AACrC,SAAO,WAAW,OAAO;AAAA,IACvB,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,KAAK,MAAM,WAAW,MAAM,WAAW;AAAA,EAC1E,CAAC;AACH;","names":["ToastContent"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { ToastDescriptionProps } from '../types/toast.types.mjs';
|
|
4
|
+
import '@impulse-ui-native/overlay';
|
|
5
|
+
import '@impulse-ui-native/primitives';
|
|
6
|
+
import '@impulse-ui-native/theme';
|
|
7
|
+
|
|
8
|
+
declare const ToastDescription: react.MemoExoticComponent<(props: ToastDescriptionProps) => react_jsx_runtime.JSX.Element>;
|
|
9
|
+
|
|
10
|
+
export { ToastDescription };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { Typography } from "@impulse-ui-native/primitives";
|
|
4
|
+
import { useComponentsTokens } from "@impulse-ui-native/theme";
|
|
5
|
+
import { useToastContext } from "../hooks/use-toast-context.hook";
|
|
6
|
+
const ToastDescription = memo(function ToastDescription2(props) {
|
|
7
|
+
useToastContext();
|
|
8
|
+
const tokens = useComponentsTokens().toast;
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
Typography.BodySmall,
|
|
11
|
+
{
|
|
12
|
+
color: tokens.descriptionColor,
|
|
13
|
+
fontSize: tokens.descriptionFontSize,
|
|
14
|
+
lineHeight: tokens.descriptionLineHeight,
|
|
15
|
+
...props
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
export {
|
|
20
|
+
ToastDescription
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=toast-description.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/toast-description.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport { Typography } from \"@impulse-ui-native/primitives\";\nimport { useComponentsTokens } from \"@impulse-ui-native/theme\";\n\nimport type { ToastDescriptionProps } from \"../types\";\nimport { useToastContext } from \"../hooks/use-toast-context.hook\";\n\nexport const ToastDescription = memo(function ToastDescription(\n props: ToastDescriptionProps,\n) {\n useToastContext();\n\n const tokens = useComponentsTokens().toast;\n\n return (\n <Typography.BodySmall\n color={tokens.descriptionColor}\n fontSize={tokens.descriptionFontSize}\n lineHeight={tokens.descriptionLineHeight}\n {...props}\n />\n );\n});\n"],"mappings":"AAgBI;AAhBJ,SAAS,YAAY;AAErB,SAAS,kBAAkB;AAC3B,SAAS,2BAA2B;AAGpC,SAAS,uBAAuB;AAEzB,MAAM,mBAAmB,KAAK,SAASA,kBAC5C,OACA;AACA,kBAAgB;AAEhB,QAAM,SAAS,oBAAoB,EAAE;AAErC,SACE;AAAA,IAAC,WAAW;AAAA,IAAX;AAAA,MACC,OAAO,OAAO;AAAA,MACd,UAAU,OAAO;AAAA,MACjB,YAAY,OAAO;AAAA,MAClB,GAAG;AAAA;AAAA,EACN;AAEJ,CAAC;","names":["ToastDescription"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { ToastIconProps } from '../types/toast.types.mjs';
|
|
4
|
+
import '@impulse-ui-native/overlay';
|
|
5
|
+
import '@impulse-ui-native/primitives';
|
|
6
|
+
import '@impulse-ui-native/theme';
|
|
7
|
+
|
|
8
|
+
declare const ToastIcon: react.MemoExoticComponent<({ children, style, ...props }: ToastIconProps) => react_jsx_runtime.JSX.Element>;
|
|
9
|
+
|
|
10
|
+
export { ToastIcon };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useMemo } from "react";
|
|
3
|
+
import { StyleSheet } from "react-native";
|
|
4
|
+
import { View } from "@impulse-ui-native/primitives";
|
|
5
|
+
import { useThemedStyles } from "@impulse-ui-native/theme";
|
|
6
|
+
import { useToastContext } from "../hooks/use-toast-context.hook";
|
|
7
|
+
const ToastIcon = memo(function ToastIcon2({
|
|
8
|
+
children,
|
|
9
|
+
style,
|
|
10
|
+
...props
|
|
11
|
+
}) {
|
|
12
|
+
const { tone } = useToastContext();
|
|
13
|
+
const styles = useThemedStyles(themedStyles, { tone }, [tone]);
|
|
14
|
+
const iconStyle = useMemo(() => [styles.icon, style], [styles.icon, style]);
|
|
15
|
+
return /* @__PURE__ */ jsx(View, { ...props, style: iconStyle, children });
|
|
16
|
+
});
|
|
17
|
+
function themedStyles(theme, { tone }) {
|
|
18
|
+
const tokens = theme.components.toast;
|
|
19
|
+
return StyleSheet.create({
|
|
20
|
+
icon: {
|
|
21
|
+
width: tokens.iconContainerSize,
|
|
22
|
+
height: tokens.iconContainerSize,
|
|
23
|
+
borderRadius: theme.radii.round,
|
|
24
|
+
alignItems: "center",
|
|
25
|
+
justifyContent: "center",
|
|
26
|
+
backgroundColor: tokens.tones[tone].contrast
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
ToastIcon
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=toast-icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/toast-icon.tsx"],"sourcesContent":["import { memo, useMemo } from \"react\";\nimport { StyleSheet } from \"react-native\";\n\nimport type { AppTheme, ToastTone } from \"@impulse-ui-native/theme\";\nimport { View } from \"@impulse-ui-native/primitives\";\nimport { useThemedStyles } from \"@impulse-ui-native/theme\";\n\nimport type { ToastIconProps } from \"../types\";\nimport { useToastContext } from \"../hooks/use-toast-context.hook\";\n\nexport const ToastIcon = memo(function ToastIcon({\n children,\n style,\n ...props\n}: ToastIconProps) {\n const { tone } = useToastContext();\n\n const styles = useThemedStyles(themedStyles, { tone }, [tone]);\n\n const iconStyle = useMemo(() => [styles.icon, style], [styles.icon, style]);\n\n return (\n <View {...props} style={iconStyle}>\n {children}\n </View>\n );\n});\n\nfunction themedStyles(theme: AppTheme, { tone }: { tone: ToastTone }) {\n const tokens = theme.components.toast;\n\n return StyleSheet.create({\n icon: {\n width: tokens.iconContainerSize,\n height: tokens.iconContainerSize,\n borderRadius: theme.radii.round,\n alignItems: \"center\",\n justifyContent: \"center\",\n backgroundColor: tokens.tones[tone].contrast,\n },\n });\n}\n"],"mappings":"AAsBI;AAtBJ,SAAS,MAAM,eAAe;AAC9B,SAAS,kBAAkB;AAG3B,SAAS,YAAY;AACrB,SAAS,uBAAuB;AAGhC,SAAS,uBAAuB;AAEzB,MAAM,YAAY,KAAK,SAASA,WAAU;AAAA,EAC/C;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAmB;AACjB,QAAM,EAAE,KAAK,IAAI,gBAAgB;AAEjC,QAAM,SAAS,gBAAgB,cAAc,EAAE,KAAK,GAAG,CAAC,IAAI,CAAC;AAE7D,QAAM,YAAY,QAAQ,MAAM,CAAC,OAAO,MAAM,KAAK,GAAG,CAAC,OAAO,MAAM,KAAK,CAAC;AAE1E,SACE,oBAAC,QAAM,GAAG,OAAO,OAAO,WACrB,UACH;AAEJ,CAAC;AAED,SAAS,aAAa,OAAiB,EAAE,KAAK,GAAwB;AACpE,QAAM,SAAS,MAAM,WAAW;AAEhC,SAAO,WAAW,OAAO;AAAA,IACvB,MAAM;AAAA,MACJ,OAAO,OAAO;AAAA,MACd,QAAQ,OAAO;AAAA,MACf,cAAc,MAAM,MAAM;AAAA,MAC1B,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,iBAAiB,OAAO,MAAM,IAAI,EAAE;AAAA,IACtC;AAAA,EACF,CAAC;AACH;","names":["ToastIcon"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { ToastRootProps, ToastContentProps, ToastTitleProps, ToastDescriptionProps, ToastIconProps, ToastActionProps, ToastCloseProps } from '../types/toast.types.mjs';
|
|
4
|
+
import '@impulse-ui-native/overlay';
|
|
5
|
+
import '@impulse-ui-native/primitives';
|
|
6
|
+
import '@impulse-ui-native/theme';
|
|
7
|
+
|
|
8
|
+
declare const Toast: {
|
|
9
|
+
Root: react.MemoExoticComponent<(props: ToastRootProps) => react_jsx_runtime.JSX.Element | null>;
|
|
10
|
+
Content: react.MemoExoticComponent<({ style, ...props }: ToastContentProps) => react_jsx_runtime.JSX.Element>;
|
|
11
|
+
Title: react.MemoExoticComponent<(props: ToastTitleProps) => react_jsx_runtime.JSX.Element>;
|
|
12
|
+
Description: react.MemoExoticComponent<(props: ToastDescriptionProps) => react_jsx_runtime.JSX.Element>;
|
|
13
|
+
Icon: react.MemoExoticComponent<({ children, style, ...props }: ToastIconProps) => react_jsx_runtime.JSX.Element>;
|
|
14
|
+
Action: react.MemoExoticComponent<({ children, closeOnPress, onPress, disabled, loading, style, ...props }: ToastActionProps) => react_jsx_runtime.JSX.Element>;
|
|
15
|
+
Close: react.MemoExoticComponent<({ children, ...props }: ToastCloseProps) => react_jsx_runtime.JSX.Element>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { Toast };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ToastAction } from "./toast-action";
|
|
2
|
+
import { ToastClose } from "./toast-close";
|
|
3
|
+
import { ToastContent } from "./toast-content";
|
|
4
|
+
import { ToastDescription } from "./toast-description";
|
|
5
|
+
import { ToastIcon } from "./toast-icon";
|
|
6
|
+
import { ToastRoot } from "./toast-root";
|
|
7
|
+
import { ToastTitle } from "./toast-title";
|
|
8
|
+
const Toast = {
|
|
9
|
+
Root: ToastRoot,
|
|
10
|
+
Content: ToastContent,
|
|
11
|
+
Title: ToastTitle,
|
|
12
|
+
Description: ToastDescription,
|
|
13
|
+
Icon: ToastIcon,
|
|
14
|
+
Action: ToastAction,
|
|
15
|
+
Close: ToastClose
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
Toast
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=toast-parts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/toast-parts.ts"],"sourcesContent":["import { ToastAction } from \"./toast-action\";\nimport { ToastClose } from \"./toast-close\";\nimport { ToastContent } from \"./toast-content\";\nimport { ToastDescription } from \"./toast-description\";\nimport { ToastIcon } from \"./toast-icon\";\nimport { ToastRoot } from \"./toast-root\";\nimport { ToastTitle } from \"./toast-title\";\n\nexport const Toast = {\n Root: ToastRoot,\n Content: ToastContent,\n Title: ToastTitle,\n Description: ToastDescription,\n Icon: ToastIcon,\n Action: ToastAction,\n Close: ToastClose,\n};\n"],"mappings":"AAAA,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAEpB,MAAM,QAAQ;AAAA,EACnB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,aAAa;AAAA,EACb,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { ToastRootProps } from '../types/toast.types.mjs';
|
|
4
|
+
import '@impulse-ui-native/overlay';
|
|
5
|
+
import '@impulse-ui-native/primitives';
|
|
6
|
+
import '@impulse-ui-native/theme';
|
|
7
|
+
|
|
8
|
+
declare const ToastRoot: react.MemoExoticComponent<(props: ToastRootProps) => react_jsx_runtime.JSX.Element | null>;
|
|
9
|
+
|
|
10
|
+
export { ToastRoot };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useMemo } from "react";
|
|
3
|
+
import { StyleSheet } from "react-native";
|
|
4
|
+
import Animated, { useAnimatedStyle } from "react-native-reanimated";
|
|
5
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
6
|
+
import { useComponentsTokens, useThemedStyles } from "@impulse-ui-native/theme";
|
|
7
|
+
import { DefaultDuration } from "../constants/toast.constants";
|
|
8
|
+
import { ToastContext } from "../contexts/toast.context";
|
|
9
|
+
import { useToastLifecycle } from "../hooks/use-toast-lifecycle.hook";
|
|
10
|
+
const ToastRoot = memo(function ToastRoot2(props) {
|
|
11
|
+
const {
|
|
12
|
+
children,
|
|
13
|
+
placement = "bottom",
|
|
14
|
+
tone = "success",
|
|
15
|
+
duration = DefaultDuration,
|
|
16
|
+
layer = 0
|
|
17
|
+
} = props;
|
|
18
|
+
const insets = useSafeAreaInsets();
|
|
19
|
+
const tokens = useComponentsTokens().toast;
|
|
20
|
+
const lifecycle = useToastLifecycle(props, duration);
|
|
21
|
+
const styles = useThemedStyles(themedStyles);
|
|
22
|
+
const { progress } = lifecycle;
|
|
23
|
+
const edgeOffset = tokens.edgeOffset;
|
|
24
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
25
|
+
opacity: progress.value,
|
|
26
|
+
transform: [
|
|
27
|
+
{
|
|
28
|
+
translateY: (1 - progress.value) * (placement === "top" ? -edgeOffset : edgeOffset)
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}));
|
|
32
|
+
const context = useMemo(
|
|
33
|
+
() => ({
|
|
34
|
+
tone,
|
|
35
|
+
interactive: lifecycle.interactive,
|
|
36
|
+
close: lifecycle.close
|
|
37
|
+
}),
|
|
38
|
+
[tone, lifecycle.interactive, lifecycle.close]
|
|
39
|
+
);
|
|
40
|
+
const containerStyle = useMemo(
|
|
41
|
+
() => [
|
|
42
|
+
styles.container,
|
|
43
|
+
{
|
|
44
|
+
left: insets.left + tokens.edgeOffset,
|
|
45
|
+
right: insets.right + tokens.edgeOffset,
|
|
46
|
+
[placement]: insets[placement] + (placement === "top" ? tokens.topOffset : tokens.edgeOffset),
|
|
47
|
+
zIndex: tokens.zIndexBase + layer
|
|
48
|
+
},
|
|
49
|
+
animatedStyle
|
|
50
|
+
],
|
|
51
|
+
[styles.container, insets, tokens, placement, layer, animatedStyle]
|
|
52
|
+
);
|
|
53
|
+
if (lifecycle.finished) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return /* @__PURE__ */ jsx(ToastContext.Provider, { value: context, children: /* @__PURE__ */ jsx(
|
|
57
|
+
Animated.View,
|
|
58
|
+
{
|
|
59
|
+
pointerEvents: lifecycle.interactive ? "auto" : "none",
|
|
60
|
+
style: containerStyle,
|
|
61
|
+
children
|
|
62
|
+
}
|
|
63
|
+
) });
|
|
64
|
+
});
|
|
65
|
+
function themedStyles(theme) {
|
|
66
|
+
const tokens = theme.components.toast;
|
|
67
|
+
return StyleSheet.create({
|
|
68
|
+
container: {
|
|
69
|
+
position: "absolute",
|
|
70
|
+
flexDirection: "row",
|
|
71
|
+
alignItems: "center",
|
|
72
|
+
gap: tokens.gap,
|
|
73
|
+
padding: tokens.padding,
|
|
74
|
+
borderRadius: tokens.borderRadius,
|
|
75
|
+
borderWidth: tokens.borderWidth,
|
|
76
|
+
borderColor: tokens.borderColor,
|
|
77
|
+
backgroundColor: tokens.backgroundColor
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
ToastRoot
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=toast-root.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/toast-root.tsx"],"sourcesContent":["import { memo, useMemo } from \"react\";\nimport { StyleSheet } from \"react-native\";\nimport Animated, { useAnimatedStyle } from \"react-native-reanimated\";\nimport { useSafeAreaInsets } from \"react-native-safe-area-context\";\n\nimport type { AppTheme } from \"@impulse-ui-native/theme\";\nimport { useComponentsTokens, useThemedStyles } from \"@impulse-ui-native/theme\";\n\nimport type { ToastRootProps } from \"../types\";\nimport { DefaultDuration } from \"../constants/toast.constants\";\nimport { ToastContext } from \"../contexts/toast.context\";\nimport { useToastLifecycle } from \"../hooks/use-toast-lifecycle.hook\";\n\nexport const ToastRoot = memo(function ToastRoot(props: ToastRootProps) {\n const {\n children,\n placement = \"bottom\",\n tone = \"success\",\n duration = DefaultDuration,\n layer = 0,\n } = props;\n\n const insets = useSafeAreaInsets();\n\n const tokens = useComponentsTokens().toast;\n\n const lifecycle = useToastLifecycle(props, duration);\n const styles = useThemedStyles(themedStyles);\n const { progress } = lifecycle;\n const edgeOffset = tokens.edgeOffset;\n const animatedStyle = useAnimatedStyle(() => ({\n opacity: progress.value,\n transform: [\n {\n translateY:\n (1 - progress.value) *\n (placement === \"top\" ? -edgeOffset : edgeOffset),\n },\n ],\n }));\n\n const context = useMemo(\n () => ({\n tone,\n interactive: lifecycle.interactive,\n close: lifecycle.close,\n }),\n [tone, lifecycle.interactive, lifecycle.close],\n );\n const containerStyle = useMemo(\n () => [\n styles.container,\n {\n left: insets.left + tokens.edgeOffset,\n right: insets.right + tokens.edgeOffset,\n [placement]:\n insets[placement] +\n (placement === \"top\" ? tokens.topOffset : tokens.edgeOffset),\n zIndex: tokens.zIndexBase + layer,\n },\n animatedStyle,\n ],\n [styles.container, insets, tokens, placement, layer, animatedStyle],\n );\n\n if (lifecycle.finished) {\n return null;\n }\n\n return (\n <ToastContext.Provider value={context}>\n <Animated.View\n pointerEvents={lifecycle.interactive ? \"auto\" : \"none\"}\n style={containerStyle}\n >\n {children}\n </Animated.View>\n </ToastContext.Provider>\n );\n});\n\nfunction themedStyles(theme: AppTheme) {\n const tokens = theme.components.toast;\n\n return StyleSheet.create({\n container: {\n position: \"absolute\",\n flexDirection: \"row\",\n alignItems: \"center\",\n gap: tokens.gap,\n padding: tokens.padding,\n borderRadius: tokens.borderRadius,\n borderWidth: tokens.borderWidth,\n borderColor: tokens.borderColor,\n backgroundColor: tokens.backgroundColor,\n },\n });\n}\n"],"mappings":"AAuEM;AAvEN,SAAS,MAAM,eAAe;AAC9B,SAAS,kBAAkB;AAC3B,OAAO,YAAY,wBAAwB;AAC3C,SAAS,yBAAyB;AAGlC,SAAS,qBAAqB,uBAAuB;AAGrD,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAE3B,MAAM,YAAY,KAAK,SAASA,WAAU,OAAuB;AACtE,QAAM;AAAA,IACJ;AAAA,IACA,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,WAAW;AAAA,IACX,QAAQ;AAAA,EACV,IAAI;AAEJ,QAAM,SAAS,kBAAkB;AAEjC,QAAM,SAAS,oBAAoB,EAAE;AAErC,QAAM,YAAY,kBAAkB,OAAO,QAAQ;AACnD,QAAM,SAAS,gBAAgB,YAAY;AAC3C,QAAM,EAAE,SAAS,IAAI;AACrB,QAAM,aAAa,OAAO;AAC1B,QAAM,gBAAgB,iBAAiB,OAAO;AAAA,IAC5C,SAAS,SAAS;AAAA,IAClB,WAAW;AAAA,MACT;AAAA,QACE,aACG,IAAI,SAAS,UACb,cAAc,QAAQ,CAAC,aAAa;AAAA,MACzC;AAAA,IACF;AAAA,EACF,EAAE;AAEF,QAAM,UAAU;AAAA,IACd,OAAO;AAAA,MACL;AAAA,MACA,aAAa,UAAU;AAAA,MACvB,OAAO,UAAU;AAAA,IACnB;AAAA,IACA,CAAC,MAAM,UAAU,aAAa,UAAU,KAAK;AAAA,EAC/C;AACA,QAAM,iBAAiB;AAAA,IACrB,MAAM;AAAA,MACJ,OAAO;AAAA,MACP;AAAA,QACE,MAAM,OAAO,OAAO,OAAO;AAAA,QAC3B,OAAO,OAAO,QAAQ,OAAO;AAAA,QAC7B,CAAC,SAAS,GACR,OAAO,SAAS,KACf,cAAc,QAAQ,OAAO,YAAY,OAAO;AAAA,QACnD,QAAQ,OAAO,aAAa;AAAA,MAC9B;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,OAAO,WAAW,QAAQ,QAAQ,WAAW,OAAO,aAAa;AAAA,EACpE;AAEA,MAAI,UAAU,UAAU;AACtB,WAAO;AAAA,EACT;AAEA,SACE,oBAAC,aAAa,UAAb,EAAsB,OAAO,SAC5B;AAAA,IAAC,SAAS;AAAA,IAAT;AAAA,MACC,eAAe,UAAU,cAAc,SAAS;AAAA,MAChD,OAAO;AAAA,MAEN;AAAA;AAAA,EACH,GACF;AAEJ,CAAC;AAED,SAAS,aAAa,OAAiB;AACrC,QAAM,SAAS,MAAM,WAAW;AAEhC,SAAO,WAAW,OAAO;AAAA,IACvB,WAAW;AAAA,MACT,UAAU;AAAA,MACV,eAAe;AAAA,MACf,YAAY;AAAA,MACZ,KAAK,OAAO;AAAA,MACZ,SAAS,OAAO;AAAA,MAChB,cAAc,OAAO;AAAA,MACrB,aAAa,OAAO;AAAA,MACpB,aAAa,OAAO;AAAA,MACpB,iBAAiB,OAAO;AAAA,IAC1B;AAAA,EACF,CAAC;AACH;","names":["ToastRoot"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { ToastTitleProps } from '../types/toast.types.mjs';
|
|
4
|
+
import '@impulse-ui-native/overlay';
|
|
5
|
+
import '@impulse-ui-native/primitives';
|
|
6
|
+
import '@impulse-ui-native/theme';
|
|
7
|
+
|
|
8
|
+
declare const ToastTitle: react.MemoExoticComponent<(props: ToastTitleProps) => react_jsx_runtime.JSX.Element>;
|
|
9
|
+
|
|
10
|
+
export { ToastTitle };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { Typography } from "@impulse-ui-native/primitives";
|
|
4
|
+
import { useComponentsTokens } from "@impulse-ui-native/theme";
|
|
5
|
+
import { useToastContext } from "../hooks/use-toast-context.hook";
|
|
6
|
+
const ToastTitle = memo(function ToastTitle2(props) {
|
|
7
|
+
useToastContext();
|
|
8
|
+
const tokens = useComponentsTokens().toast;
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
Typography.Title6,
|
|
11
|
+
{
|
|
12
|
+
color: tokens.titleColor,
|
|
13
|
+
fontSize: tokens.titleFontSize,
|
|
14
|
+
lineHeight: tokens.titleLineHeight,
|
|
15
|
+
...props
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
export {
|
|
20
|
+
ToastTitle
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=toast-title.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/toast-title.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport { Typography } from \"@impulse-ui-native/primitives\";\nimport { useComponentsTokens } from \"@impulse-ui-native/theme\";\n\nimport type { ToastTitleProps } from \"../types\";\nimport { useToastContext } from \"../hooks/use-toast-context.hook\";\n\nexport const ToastTitle = memo(function ToastTitle(props: ToastTitleProps) {\n useToastContext();\n\n const tokens = useComponentsTokens().toast;\n\n return (\n <Typography.Title6\n color={tokens.titleColor}\n fontSize={tokens.titleFontSize}\n lineHeight={tokens.titleLineHeight}\n {...props}\n />\n );\n});\n"],"mappings":"AAcI;AAdJ,SAAS,YAAY;AAErB,SAAS,kBAAkB;AAC3B,SAAS,2BAA2B;AAGpC,SAAS,uBAAuB;AAEzB,MAAM,aAAa,KAAK,SAASA,YAAW,OAAwB;AACzE,kBAAgB;AAEhB,QAAM,SAAS,oBAAoB,EAAE;AAErC,SACE;AAAA,IAAC,WAAW;AAAA,IAAX;AAAA,MACC,OAAO,OAAO;AAAA,MACd,UAAU,OAAO;AAAA,MACjB,YAAY,OAAO;AAAA,MAClB,GAAG;AAAA;AAAA,EACN;AAEJ,CAAC;","names":["ToastTitle"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { ToastProps } from '../types/toast.types.mjs';
|
|
4
|
+
import '@impulse-ui-native/overlay';
|
|
5
|
+
import '@impulse-ui-native/primitives';
|
|
6
|
+
import '@impulse-ui-native/theme';
|
|
7
|
+
|
|
8
|
+
declare const ToastComponent: react.MemoExoticComponent<({ children, title, description, action, actionProps, tone, hideIcon, hideClose, ...props }: ToastProps) => react_jsx_runtime.JSX.Element>;
|
|
9
|
+
|
|
10
|
+
export { ToastComponent };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { Icon } from "@impulse-ui-native/icon/components/icon";
|
|
4
|
+
import { XIcon } from "@impulse-ui-native/icon/icons/x";
|
|
5
|
+
import { useComponentsTokens } from "@impulse-ui-native/theme";
|
|
6
|
+
import { ToastIcons } from "../constants/toast-icons.constants";
|
|
7
|
+
import { Toast } from "./toast-parts";
|
|
8
|
+
const ToastComponent = memo(function ToastComponent2({
|
|
9
|
+
children,
|
|
10
|
+
title,
|
|
11
|
+
description,
|
|
12
|
+
action,
|
|
13
|
+
actionProps,
|
|
14
|
+
tone = "success",
|
|
15
|
+
hideIcon = false,
|
|
16
|
+
hideClose = false,
|
|
17
|
+
...props
|
|
18
|
+
}) {
|
|
19
|
+
const tokens = useComponentsTokens().toast;
|
|
20
|
+
return /* @__PURE__ */ jsxs(Toast.Root, { ...props, tone, children: [
|
|
21
|
+
!hideIcon ? /* @__PURE__ */ jsx(Toast.Icon, { children: /* @__PURE__ */ jsx(
|
|
22
|
+
Icon,
|
|
23
|
+
{
|
|
24
|
+
icon: ToastIcons[tone],
|
|
25
|
+
size: tokens.iconSize,
|
|
26
|
+
color: tokens.tones[tone].value
|
|
27
|
+
}
|
|
28
|
+
) }) : null,
|
|
29
|
+
/* @__PURE__ */ jsxs(Toast.Content, { children: [
|
|
30
|
+
title ? /* @__PURE__ */ jsx(Toast.Title, { children: title }) : null,
|
|
31
|
+
description !== null && description !== void 0 ? /* @__PURE__ */ jsx(Toast.Description, { children: description }) : null,
|
|
32
|
+
children
|
|
33
|
+
] }),
|
|
34
|
+
action !== null && action !== void 0 ? /* @__PURE__ */ jsx(Toast.Action, { ...actionProps, children: action }) : null,
|
|
35
|
+
!hideClose ? /* @__PURE__ */ jsx(Toast.Close, { children: /* @__PURE__ */ jsx(
|
|
36
|
+
Icon,
|
|
37
|
+
{
|
|
38
|
+
icon: XIcon,
|
|
39
|
+
size: tokens.iconSize,
|
|
40
|
+
color: tokens.descriptionColor
|
|
41
|
+
}
|
|
42
|
+
) }) : null
|
|
43
|
+
] });
|
|
44
|
+
});
|
|
45
|
+
export {
|
|
46
|
+
ToastComponent
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/toast.tsx"],"sourcesContent":["import { memo } from \"react\";\n\nimport { Icon } from \"@impulse-ui-native/icon/components/icon\";\nimport { XIcon } from \"@impulse-ui-native/icon/icons/x\";\nimport { useComponentsTokens } from \"@impulse-ui-native/theme\";\n\nimport type { ToastProps } from \"../types\";\nimport { ToastIcons } from \"../constants/toast-icons.constants\";\nimport { Toast } from \"./toast-parts\";\n\nexport const ToastComponent = memo(function ToastComponent({\n children,\n title,\n description,\n action,\n actionProps,\n tone = \"success\",\n hideIcon = false,\n hideClose = false,\n ...props\n}: ToastProps) {\n const tokens = useComponentsTokens().toast;\n\n return (\n <Toast.Root {...props} tone={tone}>\n {!hideIcon ? (\n <Toast.Icon>\n <Icon\n icon={ToastIcons[tone]}\n size={tokens.iconSize}\n color={tokens.tones[tone].value}\n />\n </Toast.Icon>\n ) : null}\n <Toast.Content>\n {title ? <Toast.Title>{title}</Toast.Title> : null}\n {description !== null && description !== undefined ? (\n <Toast.Description>{description}</Toast.Description>\n ) : null}\n {children}\n </Toast.Content>\n {action !== null && action !== undefined ? (\n <Toast.Action {...actionProps}>{action}</Toast.Action>\n ) : null}\n {!hideClose ? (\n <Toast.Close>\n <Icon\n icon={XIcon}\n size={tokens.iconSize}\n color={tokens.descriptionColor}\n />\n </Toast.Close>\n ) : null}\n </Toast.Root>\n );\n});\n"],"mappings":"AA2BU,cAOJ,YAPI;AA3BV,SAAS,YAAY;AAErB,SAAS,YAAY;AACrB,SAAS,aAAa;AACtB,SAAS,2BAA2B;AAGpC,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AAEf,MAAM,iBAAiB,KAAK,SAASA,gBAAe;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,GAAG;AACL,GAAe;AACb,QAAM,SAAS,oBAAoB,EAAE;AAErC,SACE,qBAAC,MAAM,MAAN,EAAY,GAAG,OAAO,MACpB;AAAA,KAAC,WACA,oBAAC,MAAM,MAAN,EACC;AAAA,MAAC;AAAA;AAAA,QACC,MAAM,WAAW,IAAI;AAAA,QACrB,MAAM,OAAO;AAAA,QACb,OAAO,OAAO,MAAM,IAAI,EAAE;AAAA;AAAA,IAC5B,GACF,IACE;AAAA,IACJ,qBAAC,MAAM,SAAN,EACE;AAAA,cAAQ,oBAAC,MAAM,OAAN,EAAa,iBAAM,IAAiB;AAAA,MAC7C,gBAAgB,QAAQ,gBAAgB,SACvC,oBAAC,MAAM,aAAN,EAAmB,uBAAY,IAC9B;AAAA,MACH;AAAA,OACH;AAAA,IACC,WAAW,QAAQ,WAAW,SAC7B,oBAAC,MAAM,QAAN,EAAc,GAAG,aAAc,kBAAO,IACrC;AAAA,IACH,CAAC,YACA,oBAAC,MAAM,OAAN,EACC;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,MAAM,OAAO;AAAA,QACb,OAAO,OAAO;AAAA;AAAA,IAChB,GACF,IACE;AAAA,KACN;AAEJ,CAAC;","names":["ToastComponent"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { SvgProps } from 'react-native-svg';
|
|
4
|
+
|
|
5
|
+
type IconVariant = "bold" | "duotone" | "fill" | "light" | "regular" | "thin";
|
|
6
|
+
interface IconWrapperProps extends SvgProps {
|
|
7
|
+
variant?: IconVariant;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare const ToastIcons: {
|
|
11
|
+
info: react.MemoExoticComponent<(props: IconWrapperProps) => react_jsx_runtime.JSX.Element>;
|
|
12
|
+
success: react.MemoExoticComponent<(props: IconWrapperProps) => react_jsx_runtime.JSX.Element>;
|
|
13
|
+
warning: react.MemoExoticComponent<(props: IconWrapperProps) => react_jsx_runtime.JSX.Element>;
|
|
14
|
+
error: react.MemoExoticComponent<(props: IconWrapperProps) => react_jsx_runtime.JSX.Element>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { ToastIcons };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CheckCircleIcon } from "@impulse-ui-native/icon/icons/check-circle";
|
|
2
|
+
import { InfoIcon } from "@impulse-ui-native/icon/icons/info";
|
|
3
|
+
import { WarningIcon } from "@impulse-ui-native/icon/icons/warning";
|
|
4
|
+
import { XCircleIcon } from "@impulse-ui-native/icon/icons/x-circle";
|
|
5
|
+
const ToastIcons = {
|
|
6
|
+
info: InfoIcon,
|
|
7
|
+
success: CheckCircleIcon,
|
|
8
|
+
warning: WarningIcon,
|
|
9
|
+
error: XCircleIcon
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
ToastIcons
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=toast-icons.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/constants/toast-icons.constants.ts"],"sourcesContent":["import { CheckCircleIcon } from \"@impulse-ui-native/icon/icons/check-circle\";\nimport { InfoIcon } from \"@impulse-ui-native/icon/icons/info\";\nimport { WarningIcon } from \"@impulse-ui-native/icon/icons/warning\";\nimport { XCircleIcon } from \"@impulse-ui-native/icon/icons/x-circle\";\n\nexport const ToastIcons = {\n info: InfoIcon,\n success: CheckCircleIcon,\n warning: WarningIcon,\n error: XCircleIcon,\n};\n"],"mappings":"AAAA,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAErB,MAAM,aAAa;AAAA,EACxB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/constants/toast.constants.ts"],"sourcesContent":["export const DefaultDuration = 4000;\nexport const EnterDuration = 180;\nexport const ExitDuration = 150;\n"],"mappings":"AAAO,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;AACtB,MAAM,eAAe;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ToastContextValue } from '../types/toast.types.mjs';
|
|
3
|
+
import '@impulse-ui-native/overlay';
|
|
4
|
+
import '@impulse-ui-native/primitives';
|
|
5
|
+
import '@impulse-ui-native/theme';
|
|
6
|
+
|
|
7
|
+
declare const ToastContext: react.Context<ToastContextValue | undefined>;
|
|
8
|
+
|
|
9
|
+
export { ToastContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/contexts/toast.context.ts"],"sourcesContent":["import { createContext } from \"react\";\n\nimport type { ToastContextValue } from \"../types\";\n\nexport const ToastContext = createContext<ToastContextValue | undefined>(\n undefined,\n);\n"],"mappings":"AAAA,SAAS,qBAAqB;AAIvB,MAAM,eAAe;AAAA,EAC1B;AACF;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ToastContextValue } from '../types/toast.types.mjs';
|
|
2
|
+
import 'react';
|
|
3
|
+
import '@impulse-ui-native/overlay';
|
|
4
|
+
import '@impulse-ui-native/primitives';
|
|
5
|
+
import '@impulse-ui-native/theme';
|
|
6
|
+
|
|
7
|
+
declare function useToastContext(): ToastContextValue;
|
|
8
|
+
|
|
9
|
+
export { useToastContext };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { ToastContext } from "../contexts/toast.context";
|
|
3
|
+
function useToastContext() {
|
|
4
|
+
const context = useContext(ToastContext);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error("Toast children must be rendered inside Toast.Root");
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
useToastContext
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=use-toast-context.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-toast-context.hook.ts"],"sourcesContent":["import { useContext } from \"react\";\n\nimport { ToastContext } from \"../contexts/toast.context\";\n\nexport function useToastContext() {\n const context = useContext(ToastContext);\n\n if (!context) {\n throw new Error(\"Toast children must be rendered inside Toast.Root\");\n }\n\n return context;\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAE3B,SAAS,oBAAoB;AAEtB,SAAS,kBAAkB;AAChC,QAAM,UAAU,WAAW,YAAY;AAEvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,mDAAmD;AAAA,EACrE;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as react_native_reanimated from 'react-native-reanimated';
|
|
2
|
+
import { ToastRootProps } from '../types/toast.types.mjs';
|
|
3
|
+
import 'react';
|
|
4
|
+
import '@impulse-ui-native/overlay';
|
|
5
|
+
import '@impulse-ui-native/primitives';
|
|
6
|
+
import '@impulse-ui-native/theme';
|
|
7
|
+
|
|
8
|
+
declare function useToastLifecycle(props: ToastRootProps, duration: number): {
|
|
9
|
+
progress: react_native_reanimated.SharedValue<number>;
|
|
10
|
+
close: () => void;
|
|
11
|
+
finished: boolean;
|
|
12
|
+
interactive: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { useToastLifecycle };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
cancelAnimation,
|
|
4
|
+
useSharedValue,
|
|
5
|
+
withTiming
|
|
6
|
+
} from "react-native-reanimated";
|
|
7
|
+
import { scheduleOnRN } from "react-native-worklets";
|
|
8
|
+
import { useEventCallback } from "@impulse-ui-native/core";
|
|
9
|
+
import { useOverlayContext } from "@impulse-ui-native/overlay";
|
|
10
|
+
import { EnterDuration, ExitDuration } from "../constants/toast.constants";
|
|
11
|
+
import { useToastTimer } from "./use-toast-timer.hook";
|
|
12
|
+
function useToastLifecycle(props, duration) {
|
|
13
|
+
const {
|
|
14
|
+
id,
|
|
15
|
+
open = true,
|
|
16
|
+
onOpen,
|
|
17
|
+
onOpenFinished,
|
|
18
|
+
onClose,
|
|
19
|
+
onCloseFinished
|
|
20
|
+
} = props;
|
|
21
|
+
const { store } = useOverlayContext();
|
|
22
|
+
const [entered, setEntered] = useState(false);
|
|
23
|
+
const [finished, setFinished] = useState(false);
|
|
24
|
+
const opened = useRef(false);
|
|
25
|
+
const closing = useRef(false);
|
|
26
|
+
const settled = useRef(false);
|
|
27
|
+
const transitionId = useRef(0);
|
|
28
|
+
const progress = useSharedValue(0);
|
|
29
|
+
const close = useEventCallback(() => store.close(id));
|
|
30
|
+
const notifyOpen = useEventCallback(() => onOpen?.(id));
|
|
31
|
+
const notifyEntered = useEventCallback(() => onOpenFinished?.(id));
|
|
32
|
+
const notifyClose = useEventCallback(() => onClose?.(id));
|
|
33
|
+
const finishClose = useEventCallback(() => {
|
|
34
|
+
if (settled.current) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
settled.current = true;
|
|
38
|
+
setFinished(true);
|
|
39
|
+
onCloseFinished?.(id);
|
|
40
|
+
});
|
|
41
|
+
const finishTransition = useEventCallback(
|
|
42
|
+
(completedTransitionId, entering) => {
|
|
43
|
+
if (transitionId.current !== completedTransitionId || settled.current) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (entering) {
|
|
47
|
+
setEntered(true);
|
|
48
|
+
notifyEntered();
|
|
49
|
+
} else {
|
|
50
|
+
finishClose();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
useToastTimer(entered && open && !finished, duration, close);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (finished) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const currentTransitionId = ++transitionId.current;
|
|
60
|
+
if (!open) {
|
|
61
|
+
const firstClose = !closing.current;
|
|
62
|
+
closing.current = true;
|
|
63
|
+
if (!opened.current) {
|
|
64
|
+
try {
|
|
65
|
+
if (firstClose) {
|
|
66
|
+
notifyClose();
|
|
67
|
+
}
|
|
68
|
+
} finally {
|
|
69
|
+
finishClose();
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
if (firstClose) {
|
|
75
|
+
notifyClose();
|
|
76
|
+
}
|
|
77
|
+
} finally {
|
|
78
|
+
progress.value = withTiming(
|
|
79
|
+
0,
|
|
80
|
+
{ duration: ExitDuration },
|
|
81
|
+
(completed) => {
|
|
82
|
+
if (completed) {
|
|
83
|
+
scheduleOnRN(finishTransition, currentTransitionId, false);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
return () => {
|
|
89
|
+
transitionId.current += 1;
|
|
90
|
+
cancelAnimation(progress);
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const firstOpen = !opened.current;
|
|
94
|
+
opened.current = true;
|
|
95
|
+
try {
|
|
96
|
+
if (firstOpen) {
|
|
97
|
+
notifyOpen();
|
|
98
|
+
}
|
|
99
|
+
} finally {
|
|
100
|
+
progress.value = withTiming(
|
|
101
|
+
1,
|
|
102
|
+
{ duration: EnterDuration },
|
|
103
|
+
(completed) => {
|
|
104
|
+
if (completed) {
|
|
105
|
+
scheduleOnRN(finishTransition, currentTransitionId, true);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
return () => {
|
|
111
|
+
transitionId.current += 1;
|
|
112
|
+
cancelAnimation(progress);
|
|
113
|
+
};
|
|
114
|
+
}, [
|
|
115
|
+
finishClose,
|
|
116
|
+
finishTransition,
|
|
117
|
+
finished,
|
|
118
|
+
notifyClose,
|
|
119
|
+
notifyEntered,
|
|
120
|
+
notifyOpen,
|
|
121
|
+
open,
|
|
122
|
+
progress
|
|
123
|
+
]);
|
|
124
|
+
return { progress, close, finished, interactive: open && !finished };
|
|
125
|
+
}
|
|
126
|
+
export {
|
|
127
|
+
useToastLifecycle
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=use-toast-lifecycle.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-toast-lifecycle.hook.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport {\n cancelAnimation,\n useSharedValue,\n withTiming,\n} from \"react-native-reanimated\";\nimport { scheduleOnRN } from \"react-native-worklets\";\n\nimport { useEventCallback } from \"@impulse-ui-native/core\";\nimport { useOverlayContext } from \"@impulse-ui-native/overlay\";\n\nimport type { ToastRootProps } from \"../types\";\nimport { EnterDuration, ExitDuration } from \"../constants/toast.constants\";\nimport { useToastTimer } from \"./use-toast-timer.hook\";\n\nexport function useToastLifecycle(props: ToastRootProps, duration: number) {\n const {\n id,\n open = true,\n onOpen,\n onOpenFinished,\n onClose,\n onCloseFinished,\n } = props;\n\n const { store } = useOverlayContext();\n\n const [entered, setEntered] = useState(false);\n const [finished, setFinished] = useState(false);\n\n const opened = useRef(false);\n const closing = useRef(false);\n const settled = useRef(false);\n const transitionId = useRef(0);\n\n const progress = useSharedValue(0);\n\n const close = useEventCallback(() => store.close(id));\n\n const notifyOpen = useEventCallback(() => onOpen?.(id));\n\n const notifyEntered = useEventCallback(() => onOpenFinished?.(id));\n\n const notifyClose = useEventCallback(() => onClose?.(id));\n\n const finishClose = useEventCallback(() => {\n if (settled.current) {\n return;\n }\n\n settled.current = true;\n\n setFinished(true);\n\n onCloseFinished?.(id);\n });\n\n const finishTransition = useEventCallback(\n (completedTransitionId: number, entering: boolean) => {\n if (transitionId.current !== completedTransitionId || settled.current) {\n return;\n }\n\n if (entering) {\n setEntered(true);\n\n notifyEntered();\n } else {\n finishClose();\n }\n },\n );\n\n useToastTimer(entered && open && !finished, duration, close);\n\n useEffect(() => {\n if (finished) {\n return;\n }\n\n const currentTransitionId = ++transitionId.current;\n\n if (!open) {\n const firstClose = !closing.current;\n\n closing.current = true;\n\n if (!opened.current) {\n try {\n if (firstClose) {\n notifyClose();\n }\n } finally {\n finishClose();\n }\n\n return;\n }\n\n try {\n if (firstClose) {\n notifyClose();\n }\n } finally {\n progress.value = withTiming(\n 0,\n { duration: ExitDuration },\n (completed) => {\n if (completed) {\n scheduleOnRN(finishTransition, currentTransitionId, false);\n }\n },\n );\n }\n\n return () => {\n transitionId.current += 1;\n\n cancelAnimation(progress);\n };\n }\n\n const firstOpen = !opened.current;\n\n opened.current = true;\n\n try {\n if (firstOpen) {\n notifyOpen();\n }\n } finally {\n progress.value = withTiming(\n 1,\n { duration: EnterDuration },\n (completed) => {\n if (completed) {\n scheduleOnRN(finishTransition, currentTransitionId, true);\n }\n },\n );\n }\n\n return () => {\n transitionId.current += 1;\n\n cancelAnimation(progress);\n };\n }, [\n finishClose,\n finishTransition,\n finished,\n notifyClose,\n notifyEntered,\n notifyOpen,\n open,\n progress,\n ]);\n\n return { progress, close, finished, interactive: open && !finished };\n}\n"],"mappings":"AAAA,SAAS,WAAW,QAAQ,gBAAgB;AAC5C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AAE7B,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAGlC,SAAS,eAAe,oBAAoB;AAC5C,SAAS,qBAAqB;AAEvB,SAAS,kBAAkB,OAAuB,UAAkB;AACzE,QAAM;AAAA,IACJ;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,EAAE,MAAM,IAAI,kBAAkB;AAEpC,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAE9C,QAAM,SAAS,OAAO,KAAK;AAC3B,QAAM,UAAU,OAAO,KAAK;AAC5B,QAAM,UAAU,OAAO,KAAK;AAC5B,QAAM,eAAe,OAAO,CAAC;AAE7B,QAAM,WAAW,eAAe,CAAC;AAEjC,QAAM,QAAQ,iBAAiB,MAAM,MAAM,MAAM,EAAE,CAAC;AAEpD,QAAM,aAAa,iBAAiB,MAAM,SAAS,EAAE,CAAC;AAEtD,QAAM,gBAAgB,iBAAiB,MAAM,iBAAiB,EAAE,CAAC;AAEjE,QAAM,cAAc,iBAAiB,MAAM,UAAU,EAAE,CAAC;AAExD,QAAM,cAAc,iBAAiB,MAAM;AACzC,QAAI,QAAQ,SAAS;AACnB;AAAA,IACF;AAEA,YAAQ,UAAU;AAElB,gBAAY,IAAI;AAEhB,sBAAkB,EAAE;AAAA,EACtB,CAAC;AAED,QAAM,mBAAmB;AAAA,IACvB,CAAC,uBAA+B,aAAsB;AACpD,UAAI,aAAa,YAAY,yBAAyB,QAAQ,SAAS;AACrE;AAAA,MACF;AAEA,UAAI,UAAU;AACZ,mBAAW,IAAI;AAEf,sBAAc;AAAA,MAChB,OAAO;AACL,oBAAY;AAAA,MACd;AAAA,IACF;AAAA,EACF;AAEA,gBAAc,WAAW,QAAQ,CAAC,UAAU,UAAU,KAAK;AAE3D,YAAU,MAAM;AACd,QAAI,UAAU;AACZ;AAAA,IACF;AAEA,UAAM,sBAAsB,EAAE,aAAa;AAE3C,QAAI,CAAC,MAAM;AACT,YAAM,aAAa,CAAC,QAAQ;AAE5B,cAAQ,UAAU;AAElB,UAAI,CAAC,OAAO,SAAS;AACnB,YAAI;AACF,cAAI,YAAY;AACd,wBAAY;AAAA,UACd;AAAA,QACF,UAAE;AACA,sBAAY;AAAA,QACd;AAEA;AAAA,MACF;AAEA,UAAI;AACF,YAAI,YAAY;AACd,sBAAY;AAAA,QACd;AAAA,MACF,UAAE;AACA,iBAAS,QAAQ;AAAA,UACf;AAAA,UACA,EAAE,UAAU,aAAa;AAAA,UACzB,CAAC,cAAc;AACb,gBAAI,WAAW;AACb,2BAAa,kBAAkB,qBAAqB,KAAK;AAAA,YAC3D;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAEA,aAAO,MAAM;AACX,qBAAa,WAAW;AAExB,wBAAgB,QAAQ;AAAA,MAC1B;AAAA,IACF;AAEA,UAAM,YAAY,CAAC,OAAO;AAE1B,WAAO,UAAU;AAEjB,QAAI;AACF,UAAI,WAAW;AACb,mBAAW;AAAA,MACb;AAAA,IACF,UAAE;AACA,eAAS,QAAQ;AAAA,QACf;AAAA,QACA,EAAE,UAAU,cAAc;AAAA,QAC1B,CAAC,cAAc;AACb,cAAI,WAAW;AACb,yBAAa,kBAAkB,qBAAqB,IAAI;AAAA,UAC1D;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,WAAO,MAAM;AACX,mBAAa,WAAW;AAExB,sBAAgB,QAAQ;AAAA,IAC1B;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO,EAAE,UAAU,OAAO,UAAU,aAAa,QAAQ,CAAC,SAAS;AACrE;","names":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { AppState } from "react-native";
|
|
3
|
+
import { useEventCallback } from "@impulse-ui-native/core";
|
|
4
|
+
function useToastTimer(active, duration, close) {
|
|
5
|
+
const dismiss = useEventCallback(close);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (!active || !Number.isFinite(duration) || duration <= 0) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
let remaining = duration;
|
|
11
|
+
let startedAt = 0;
|
|
12
|
+
let timeout;
|
|
13
|
+
const pause = () => {
|
|
14
|
+
if (timeout === void 0) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
clearTimeout(timeout);
|
|
18
|
+
timeout = void 0;
|
|
19
|
+
remaining = Math.max(0, remaining - (Date.now() - startedAt));
|
|
20
|
+
};
|
|
21
|
+
const resume = () => {
|
|
22
|
+
if (timeout !== void 0) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
startedAt = Date.now();
|
|
26
|
+
timeout = setTimeout(() => {
|
|
27
|
+
timeout = void 0;
|
|
28
|
+
dismiss();
|
|
29
|
+
}, remaining);
|
|
30
|
+
};
|
|
31
|
+
const subscription = AppState.addEventListener("change", (state) => {
|
|
32
|
+
if (state === "active") {
|
|
33
|
+
resume();
|
|
34
|
+
} else {
|
|
35
|
+
pause();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
if (AppState.currentState === "active") {
|
|
39
|
+
resume();
|
|
40
|
+
}
|
|
41
|
+
return () => {
|
|
42
|
+
pause();
|
|
43
|
+
subscription.remove();
|
|
44
|
+
};
|
|
45
|
+
}, [active, dismiss, duration]);
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
useToastTimer
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=use-toast-timer.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-toast-timer.hook.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { AppState } from \"react-native\";\n\nimport { useEventCallback } from \"@impulse-ui-native/core\";\n\nexport function useToastTimer(\n active: boolean,\n duration: number,\n close: () => void,\n) {\n const dismiss = useEventCallback(close);\n\n useEffect(() => {\n if (!active || !Number.isFinite(duration) || duration <= 0) {\n return;\n }\n\n let remaining = duration;\n let startedAt = 0;\n let timeout: ReturnType<typeof setTimeout> | undefined;\n\n const pause = () => {\n if (timeout === undefined) {\n return;\n }\n\n clearTimeout(timeout);\n\n timeout = undefined;\n remaining = Math.max(0, remaining - (Date.now() - startedAt));\n };\n\n const resume = () => {\n if (timeout !== undefined) {\n return;\n }\n\n startedAt = Date.now();\n timeout = setTimeout(() => {\n timeout = undefined;\n\n dismiss();\n }, remaining);\n };\n\n const subscription = AppState.addEventListener(\"change\", (state) => {\n if (state === \"active\") {\n resume();\n } else {\n pause();\n }\n });\n\n if (AppState.currentState === \"active\") {\n resume();\n }\n\n return () => {\n pause();\n subscription.remove();\n };\n }, [active, dismiss, duration]);\n}\n"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AAEzB,SAAS,wBAAwB;AAE1B,SAAS,cACd,QACA,UACA,OACA;AACA,QAAM,UAAU,iBAAiB,KAAK;AAEtC,YAAU,MAAM;AACd,QAAI,CAAC,UAAU,CAAC,OAAO,SAAS,QAAQ,KAAK,YAAY,GAAG;AAC1D;AAAA,IACF;AAEA,QAAI,YAAY;AAChB,QAAI,YAAY;AAChB,QAAI;AAEJ,UAAM,QAAQ,MAAM;AAClB,UAAI,YAAY,QAAW;AACzB;AAAA,MACF;AAEA,mBAAa,OAAO;AAEpB,gBAAU;AACV,kBAAY,KAAK,IAAI,GAAG,aAAa,KAAK,IAAI,IAAI,UAAU;AAAA,IAC9D;AAEA,UAAM,SAAS,MAAM;AACnB,UAAI,YAAY,QAAW;AACzB;AAAA,MACF;AAEA,kBAAY,KAAK,IAAI;AACrB,gBAAU,WAAW,MAAM;AACzB,kBAAU;AAEV,gBAAQ;AAAA,MACV,GAAG,SAAS;AAAA,IACd;AAEA,UAAM,eAAe,SAAS,iBAAiB,UAAU,CAAC,UAAU;AAClE,UAAI,UAAU,UAAU;AACtB,eAAO;AAAA,MACT,OAAO;AACL,cAAM;AAAA,MACR;AAAA,IACF,CAAC;AAED,QAAI,SAAS,iBAAiB,UAAU;AACtC,aAAO;AAAA,IACT;AAEA,WAAO,MAAM;AACX,YAAM;AACN,mBAAa,OAAO;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,QAAQ,SAAS,QAAQ,CAAC;AAChC;","names":[]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Toast } from './components/index.mjs';
|
|
2
|
+
export { ToastActionProps, ToastCloseProps, ToastContentProps, ToastContextValue, ToastDescriptionProps, ToastIconProps, ToastPlacement, ToastProps, ToastRootProps, ToastTitleProps } from './types/toast.types.mjs';
|
|
3
|
+
import 'react/jsx-runtime';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '@impulse-ui-native/overlay';
|
|
6
|
+
import '@impulse-ui-native/primitives';
|
|
7
|
+
import '@impulse-ui-native/theme';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./types\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ToastActionProps, ToastCloseProps, ToastContentProps, ToastContextValue, ToastDescriptionProps, ToastIconProps, ToastPlacement, ToastProps, ToastRootProps, ToastTitleProps } from './toast.types.mjs';
|
|
2
|
+
import 'react';
|
|
3
|
+
import '@impulse-ui-native/overlay';
|
|
4
|
+
import '@impulse-ui-native/primitives';
|
|
5
|
+
import '@impulse-ui-native/theme';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export * from \"./toast.types\";\n"],"mappings":"AAAA,cAAc;","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { OverlayComponentProps } from '@impulse-ui-native/overlay';
|
|
3
|
+
import { ButtonProps, ViewProps, TextProps } from '@impulse-ui-native/primitives';
|
|
4
|
+
import { ToastTone } from '@impulse-ui-native/theme';
|
|
5
|
+
|
|
6
|
+
type ToastPlacement = "top" | "bottom";
|
|
7
|
+
interface ToastRootProps extends OverlayComponentProps {
|
|
8
|
+
placement?: ToastPlacement;
|
|
9
|
+
tone?: ToastTone;
|
|
10
|
+
/** Milliseconds after entry completes. Zero persists until dismissed. */
|
|
11
|
+
duration?: number;
|
|
12
|
+
}
|
|
13
|
+
interface ToastProps extends ToastRootProps {
|
|
14
|
+
description?: ReactNode;
|
|
15
|
+
action?: ReactNode;
|
|
16
|
+
actionProps?: Omit<ToastActionProps, "children">;
|
|
17
|
+
hideIcon?: boolean;
|
|
18
|
+
hideClose?: boolean;
|
|
19
|
+
}
|
|
20
|
+
type ToastContentProps = ViewProps;
|
|
21
|
+
type ToastTitleProps = TextProps;
|
|
22
|
+
type ToastDescriptionProps = TextProps;
|
|
23
|
+
type ToastIconProps = ViewProps;
|
|
24
|
+
interface ToastActionProps extends Omit<ButtonProps, "children" | "size" | "variant"> {
|
|
25
|
+
children?: ReactNode;
|
|
26
|
+
closeOnPress?: boolean;
|
|
27
|
+
}
|
|
28
|
+
type ToastCloseProps = Omit<ToastActionProps, "closeOnPress">;
|
|
29
|
+
interface ToastContextValue {
|
|
30
|
+
tone: ToastTone;
|
|
31
|
+
interactive: boolean;
|
|
32
|
+
close: () => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type { ToastActionProps, ToastCloseProps, ToastContentProps, ToastContextValue, ToastDescriptionProps, ToastIconProps, ToastPlacement, ToastProps, ToastRootProps, ToastTitleProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=toast.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@impulse-ui-native/toast",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "6.0.0",
|
|
4
|
+
"description": "Compound toast notifications for ImpulseUI Native.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react-native",
|
|
7
|
+
"toast",
|
|
8
|
+
"notifications",
|
|
9
|
+
"components"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"source": "src/index.ts",
|
|
13
|
+
"module": "dist/index.js",
|
|
14
|
+
"types": "dist/index.d.mts",
|
|
15
|
+
"react-native": "src/index.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.mts",
|
|
19
|
+
"react-native": "./src/index.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@impulse-ui-native/theme": "6.0.0",
|
|
31
|
+
"@impulse-ui-native/overlay": "6.0.0",
|
|
32
|
+
"@impulse-ui-native/primitives": "6.0.0",
|
|
33
|
+
"@impulse-ui-native/core": "6.0.0",
|
|
34
|
+
"@impulse-ui-native/icon": "6.0.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/react": "~19.2.14",
|
|
38
|
+
"eslint": "^9.38.0",
|
|
39
|
+
"prettier": "^3.6.2",
|
|
40
|
+
"react": "19.2.3",
|
|
41
|
+
"react-native": "0.86.2",
|
|
42
|
+
"react-native-reanimated": "4.5.1",
|
|
43
|
+
"react-native-worklets": "0.10.1",
|
|
44
|
+
"react-native-safe-area-context": "~5.7.0",
|
|
45
|
+
"typescript": "~6.0.3",
|
|
46
|
+
"react-native-svg": "15.15.4",
|
|
47
|
+
"@impulse-ui-native/prettier-config": "1.0.0",
|
|
48
|
+
"@impulse-ui-native/eslint-config": "1.0.0",
|
|
49
|
+
"@impulse-ui-native/tsconfig": "1.0.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"react": ">=18",
|
|
53
|
+
"react-native": ">=0.73",
|
|
54
|
+
"react-native-reanimated": ">=4.0.0",
|
|
55
|
+
"react-native-worklets": ">=0.5",
|
|
56
|
+
"react-native-safe-area-context": ">=5.0.0",
|
|
57
|
+
"react-native-svg": ">=13.9.0"
|
|
58
|
+
},
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public"
|
|
61
|
+
},
|
|
62
|
+
"prettier": "@impulse-ui-native/prettier-config",
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsup --config tsup.config.ts",
|
|
65
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
66
|
+
"lint": "pnpm exec eslint . --fix",
|
|
67
|
+
"format": "prettier --write \"./**/*.{ts,tsx,js,jsx,json,md}\" --ignore-path ../../.prettierignore",
|
|
68
|
+
"test": "node --test tests/*.test.mjs"
|
|
69
|
+
}
|
|
6
70
|
}
|