react-native-notitoast 0.0.0-stage → 2.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 +201 -2
- package/lib/commonjs/ToastItem.js +504 -0
- package/lib/commonjs/ToastItem.js.map +1 -0
- package/lib/commonjs/ToastProvider.js +84 -0
- package/lib/commonjs/ToastProvider.js.map +1 -0
- package/lib/commonjs/index.js +26 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/theme.js +41 -0
- package/lib/commonjs/theme.js.map +1 -0
- package/lib/commonjs/toast.js +39 -0
- package/lib/commonjs/toast.js.map +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/ToastItem.js +500 -0
- package/lib/module/ToastItem.js.map +1 -0
- package/lib/module/ToastProvider.js +80 -0
- package/lib/module/ToastProvider.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/theme.js +37 -0
- package/lib/module/theme.js.map +1 -0
- package/lib/module/toast.js +33 -0
- package/lib/module/toast.js.map +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/src/ToastItem.d.ts +12 -0
- package/lib/typescript/src/ToastItem.d.ts.map +1 -0
- package/lib/typescript/src/ToastProvider.d.ts +7 -0
- package/lib/typescript/src/ToastProvider.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/theme.d.ts +21 -0
- package/lib/typescript/src/theme.d.ts.map +1 -0
- package/lib/typescript/src/toast.d.ts +23 -0
- package/lib/typescript/src/toast.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +93 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +77 -6
- package/src/ToastItem.tsx +597 -0
- package/src/ToastProvider.tsx +93 -0
- package/src/index.ts +14 -0
- package/src/theme.ts +39 -0
- package/src/toast.ts +51 -0
- package/src/types.ts +109 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { Platform, StatusBar, StyleSheet, View, useColorScheme } from 'react-native';
|
|
5
|
+
import { ToastItem } from './ToastItem';
|
|
6
|
+
import { setToastHandler } from './toast';
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
export function ToastProvider({
|
|
9
|
+
children,
|
|
10
|
+
...config
|
|
11
|
+
}) {
|
|
12
|
+
const [queue, setQueue] = useState([]);
|
|
13
|
+
const counter = useRef(0);
|
|
14
|
+
const systemScheme = useColorScheme();
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
setToastHandler({
|
|
17
|
+
show: options => {
|
|
18
|
+
const id = options.id ?? `toast-${++counter.current}`;
|
|
19
|
+
setQueue(q => {
|
|
20
|
+
const existing = q.find(t => t.id === id);
|
|
21
|
+
if (existing) {
|
|
22
|
+
return q.map(t => t.id === id ? {
|
|
23
|
+
...t,
|
|
24
|
+
...options,
|
|
25
|
+
id,
|
|
26
|
+
rev: t.rev + 1,
|
|
27
|
+
dismissing: false
|
|
28
|
+
} : t);
|
|
29
|
+
}
|
|
30
|
+
return [...q, {
|
|
31
|
+
...options,
|
|
32
|
+
id,
|
|
33
|
+
rev: 0
|
|
34
|
+
}];
|
|
35
|
+
});
|
|
36
|
+
return id;
|
|
37
|
+
},
|
|
38
|
+
hide: id => {
|
|
39
|
+
setQueue(q => {
|
|
40
|
+
const target = id ?? q[0]?.id;
|
|
41
|
+
return q.flatMap((t, i) => t.id !== target ? [t] : i === 0 ? [{
|
|
42
|
+
...t,
|
|
43
|
+
dismissing: true
|
|
44
|
+
}] : []);
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
hideAll: () => {
|
|
48
|
+
setQueue(q => q[0] ? [{
|
|
49
|
+
...q[0],
|
|
50
|
+
dismissing: true
|
|
51
|
+
}] : []);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return () => setToastHandler(null);
|
|
55
|
+
}, []);
|
|
56
|
+
const current = queue[0];
|
|
57
|
+
const handleExited = useCallback(id => {
|
|
58
|
+
setQueue(q => q.filter(t => t.id !== id));
|
|
59
|
+
}, []);
|
|
60
|
+
const scheme = config.theme === 'light' || config.theme === 'dark' ? config.theme : systemScheme === 'dark' ? 'dark' : 'light';
|
|
61
|
+
const topOffset = config.topOffset ?? (Platform.OS === 'android' ? (StatusBar.currentHeight ?? 24) + 8 : 54);
|
|
62
|
+
const bottomOffset = config.bottomOffset ?? 40;
|
|
63
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
64
|
+
style: styles.root,
|
|
65
|
+
children: [children, current ? /*#__PURE__*/_jsx(ToastItem, {
|
|
66
|
+
toast: current,
|
|
67
|
+
config: config,
|
|
68
|
+
scheme: scheme,
|
|
69
|
+
topOffset: topOffset,
|
|
70
|
+
bottomOffset: bottomOffset,
|
|
71
|
+
onExited: () => handleExited(current.id)
|
|
72
|
+
}, current.id) : null]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
const styles = StyleSheet.create({
|
|
76
|
+
root: {
|
|
77
|
+
flex: 1
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=ToastProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useRef","useState","Platform","StatusBar","StyleSheet","View","useColorScheme","ToastItem","setToastHandler","jsx","_jsx","jsxs","_jsxs","ToastProvider","children","config","queue","setQueue","counter","systemScheme","show","options","id","current","q","existing","find","t","map","rev","dismissing","hide","target","flatMap","i","hideAll","handleExited","filter","scheme","theme","topOffset","OS","currentHeight","bottomOffset","style","styles","root","toast","onExited","create","flex"],"sourceRoot":"..\\..\\src","sources":["ToastProvider.tsx"],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AE,KAAK,SAAS,GAAG,CAACtC,SAAS,CAACuC,aAAa,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;EACxE,MAAMC,YAAY,GAAG5B,MAAM,CAAC4B,YAAY,IAAI,EAAE;EAE9C,oBACE/B,KAAA,CAACP,IAAI;IAACuC,KAAK,EAAEC,MAAM,CAACC,IAAK;IAAAhC,QAAA,GACtBA,QAAQ,EACRS,OAAO,gBACNb,IAAA,CAACH,SAAS;MAERwC,KAAK,EAAExB,OAAQ;MACfR,MAAM,EAAEA,MAAO;MACfuB,MAAM,EAAEA,MAAO;MACfE,SAAS,EAAEA,SAAU;MACrBG,YAAY,EAAEA,YAAa;MAC3BK,QAAQ,EAAEA,CAAA,KAAMZ,YAAY,CAACb,OAAO,CAACD,EAAE;IAAE,GANpCC,OAAO,CAACD,EAOd,CAAC,GACA,IAAI;EAAA,CACJ,CAAC;AAEX;AAEA,MAAMuB,MAAM,GAAGzC,UAAU,CAAC6C,MAAM,CAAC;EAC/BH,IAAI,EAAE;IAAEI,IAAI,EAAE;EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ToastProvider","toast","useToast"],"sourceRoot":"..\\..\\src","sources":["index.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,iBAAiB;AAE/C,SAASC,KAAK,EAAEC,QAAQ,QAAQ,SAAS","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const typeColors = {
|
|
4
|
+
success: '#16A34A',
|
|
5
|
+
error: '#DC2626',
|
|
6
|
+
warning: '#F59E0B',
|
|
7
|
+
info: '#2563EB'
|
|
8
|
+
};
|
|
9
|
+
export const typeGlyphs = {
|
|
10
|
+
success: '✓',
|
|
11
|
+
error: '✕',
|
|
12
|
+
warning: '!',
|
|
13
|
+
info: 'i'
|
|
14
|
+
};
|
|
15
|
+
export const defaultDurations = {
|
|
16
|
+
success: 3500,
|
|
17
|
+
error: 5000,
|
|
18
|
+
warning: 4000,
|
|
19
|
+
info: 3500
|
|
20
|
+
};
|
|
21
|
+
export const palettes = {
|
|
22
|
+
light: {
|
|
23
|
+
card: '#FFFFFF',
|
|
24
|
+
border: 'rgba(0,0,0,0.06)',
|
|
25
|
+
title: '#111827',
|
|
26
|
+
message: '#4B5563',
|
|
27
|
+
track: 'rgba(0,0,0,0.05)'
|
|
28
|
+
},
|
|
29
|
+
dark: {
|
|
30
|
+
card: '#1F2023',
|
|
31
|
+
border: 'rgba(255,255,255,0.08)',
|
|
32
|
+
title: '#F9FAFB',
|
|
33
|
+
message: '#D1D5DB',
|
|
34
|
+
track: 'rgba(255,255,255,0.08)'
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["typeColors","success","error","warning","info","typeGlyphs","defaultDurations","palettes","light","card","border","title","message","track","dark"],"sourceRoot":"..\\..\\src","sources":["theme.ts"],"mappings":";;AAEA,OAAO,MAAMA,UAAqC,GAAG;EACnDC,OAAO,EAAE,SAAS;EAClBC,KAAK,EAAE,SAAS;EAChBC,OAAO,EAAE,SAAS;EAClBC,IAAI,EAAE;AACR,CAAC;AAED,OAAO,MAAMC,UAAqC,GAAG;EACnDJ,OAAO,EAAE,GAAG;EACZC,KAAK,EAAE,GAAG;EACVC,OAAO,EAAE,GAAG;EACZC,IAAI,EAAE;AACR,CAAC;AAED,OAAO,MAAME,gBAA2C,GAAG;EACzDL,OAAO,EAAE,IAAI;EACbC,KAAK,EAAE,IAAI;EACXC,OAAO,EAAE,IAAI;EACbC,IAAI,EAAE;AACR,CAAC;AAED,OAAO,MAAMG,QAAQ,GAAG;EACtBC,KAAK,EAAE;IACLC,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE,kBAAkB;IAC1BC,KAAK,EAAE,SAAS;IAChBC,OAAO,EAAE,SAAS;IAClBC,KAAK,EAAE;EACT,CAAC;EACDC,IAAI,EAAE;IACJL,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE,wBAAwB;IAChCC,KAAK,EAAE,SAAS;IAChBC,OAAO,EAAE,SAAS;IAClBC,KAAK,EAAE;EACT;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
let handler = null;
|
|
4
|
+
|
|
5
|
+
/** @internal */
|
|
6
|
+
export function setToastHandler(next) {
|
|
7
|
+
handler = next;
|
|
8
|
+
}
|
|
9
|
+
function show(options) {
|
|
10
|
+
if (!handler) {
|
|
11
|
+
console.warn('[react-native-notitoast] <ToastProvider> is not mounted. Wrap your app root with it.');
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
14
|
+
return handler.show(options);
|
|
15
|
+
}
|
|
16
|
+
const make = type => (title, message, options) => show({
|
|
17
|
+
...options,
|
|
18
|
+
type,
|
|
19
|
+
title,
|
|
20
|
+
message
|
|
21
|
+
});
|
|
22
|
+
export const toast = Object.assign(show, {
|
|
23
|
+
success: make('success'),
|
|
24
|
+
error: make('error'),
|
|
25
|
+
warning: make('warning'),
|
|
26
|
+
info: make('info'),
|
|
27
|
+
hide: id => handler?.hide(id),
|
|
28
|
+
hideAll: () => handler?.hideAll()
|
|
29
|
+
});
|
|
30
|
+
export function useToast() {
|
|
31
|
+
return toast;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["handler","setToastHandler","next","show","options","console","warn","make","type","title","message","toast","Object","assign","success","error","warning","info","hide","id","hideAll","useToast"],"sourceRoot":"..\\..\\src","sources":["toast.ts"],"mappings":";;AAQA,IAAIA,OAAuB,GAAG,IAAI;;AAElC;AACA,OAAO,SAASC,eAAeA,CAACC,IAAoB,EAAE;EACpDF,OAAO,GAAGE,IAAI;AAChB;AAEA,SAASC,IAAIA,CAACC,OAAqB,EAAU;EAC3C,IAAI,CAACJ,OAAO,EAAE;IACZK,OAAO,CAACC,IAAI,CACV,sFACF,CAAC;IACD,OAAO,EAAE;EACX;EACA,OAAON,OAAO,CAACG,IAAI,CAACC,OAAO,CAAC;AAC9B;AASA,MAAMG,IAAI,GACPC,IAAe,IAChB,CAACC,KAAK,EAAEC,OAAO,EAAEN,OAAO,KACtBD,IAAI,CAAC;EAAE,GAAGC,OAAO;EAAEI,IAAI;EAAEC,KAAK;EAAEC;AAAQ,CAAC,CAAC;AAE9C,OAAO,MAAMC,KAAK,GAAGC,MAAM,CAACC,MAAM,CAACV,IAAI,EAAE;EACvCW,OAAO,EAAEP,IAAI,CAAC,SAAS,CAAC;EACxBQ,KAAK,EAAER,IAAI,CAAC,OAAO,CAAC;EACpBS,OAAO,EAAET,IAAI,CAAC,SAAS,CAAC;EACxBU,IAAI,EAAEV,IAAI,CAAC,MAAM,CAAC;EAClBW,IAAI,EAAGC,EAAW,IAAKnB,OAAO,EAAEkB,IAAI,CAACC,EAAE,CAAC;EACxCC,OAAO,EAAEA,CAAA,KAAMpB,OAAO,EAAEoB,OAAO,CAAC;AAClC,CAAC,CAAC;AAIF,OAAO,SAASC,QAAQA,CAAA,EAAU;EAChC,OAAOV,KAAK;AACd","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"..\\..\\src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ToastConfig, ToastData } from './types';
|
|
2
|
+
interface Props {
|
|
3
|
+
toast: ToastData;
|
|
4
|
+
config: ToastConfig;
|
|
5
|
+
scheme: 'light' | 'dark';
|
|
6
|
+
topOffset: number;
|
|
7
|
+
bottomOffset: number;
|
|
8
|
+
onExited: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function ToastItem({ toast, config, scheme, topOffset, bottomOffset, onExited, }: Props): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=ToastItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastItem.d.ts","sourceRoot":"","sources":["../../../src/ToastItem.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAmB,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIvE,UAAU,KAAK;IACb,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAcD,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,MAAM,EACN,MAAM,EACN,SAAS,EACT,YAAY,EACZ,QAAQ,GACT,EAAE,KAAK,+BAubP"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ToastConfig } from './types';
|
|
3
|
+
export interface ToastProviderProps extends ToastConfig {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare function ToastProvider({ children, ...config }: ToastProviderProps): import("react").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=ToastProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../../../src/ToastProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAUvC,OAAO,KAAK,EAAE,WAAW,EAA2B,MAAM,SAAS,CAAC;AAEpE,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,EAAE,kBAAkB,+BAuExE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ToastProvider } from './ToastProvider';
|
|
2
|
+
export type { ToastProviderProps } from './ToastProvider';
|
|
3
|
+
export { toast, useToast } from './toast';
|
|
4
|
+
export type { Toast } from './toast';
|
|
5
|
+
export type { ToastAppearance, ToastConfig, ToastImagePosition, ToastOptions, ToastPosition, ToastTheme, ToastType, ToastVariant, } from './types';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1C,YAAY,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,YAAY,EACV,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,UAAU,EACV,SAAS,EACT,YAAY,GACb,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ToastType } from './types';
|
|
2
|
+
export declare const typeColors: Record<ToastType, string>;
|
|
3
|
+
export declare const typeGlyphs: Record<ToastType, string>;
|
|
4
|
+
export declare const defaultDurations: Record<ToastType, number>;
|
|
5
|
+
export declare const palettes: {
|
|
6
|
+
light: {
|
|
7
|
+
card: string;
|
|
8
|
+
border: string;
|
|
9
|
+
title: string;
|
|
10
|
+
message: string;
|
|
11
|
+
track: string;
|
|
12
|
+
};
|
|
13
|
+
dark: {
|
|
14
|
+
card: string;
|
|
15
|
+
border: string;
|
|
16
|
+
title: string;
|
|
17
|
+
message: string;
|
|
18
|
+
track: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAKhD,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAKhD,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAKtD,CAAC;AAEF,eAAO,MAAM,QAAQ;IACnB,KAAK;QACH,IAAI;QACJ,MAAM;QACN,KAAK;QACL,OAAO;QACP,KAAK;;IAEP,IAAI;QACF,IAAI;QACJ,MAAM;QACN,KAAK;QACL,OAAO;QACP,KAAK;;CAER,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ToastOptions } from './types';
|
|
2
|
+
interface Handler {
|
|
3
|
+
show: (options: ToastOptions) => string;
|
|
4
|
+
hide: (id?: string) => void;
|
|
5
|
+
hideAll: () => void;
|
|
6
|
+
}
|
|
7
|
+
/** @internal */
|
|
8
|
+
export declare function setToastHandler(next: Handler | null): void;
|
|
9
|
+
declare function show(options: ToastOptions): string;
|
|
10
|
+
type ShortcutOptions = Omit<ToastOptions, 'type' | 'title' | 'message'>;
|
|
11
|
+
type Shortcut = (title: string, message?: string, options?: ShortcutOptions) => string;
|
|
12
|
+
export declare const toast: typeof show & {
|
|
13
|
+
success: Shortcut;
|
|
14
|
+
error: Shortcut;
|
|
15
|
+
warning: Shortcut;
|
|
16
|
+
info: Shortcut;
|
|
17
|
+
hide: (id?: string) => void | undefined;
|
|
18
|
+
hideAll: () => void | undefined;
|
|
19
|
+
};
|
|
20
|
+
export type Toast = typeof toast;
|
|
21
|
+
export declare function useToast(): Toast;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=toast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast.d.ts","sourceRoot":"","sources":["../../../src/toast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAa,MAAM,SAAS,CAAC;AAEvD,UAAU,OAAO;IACf,IAAI,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,MAAM,CAAC;IACxC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAID,gBAAgB;AAChB,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,QAEnD;AAED,iBAAS,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAQ3C;AAED,KAAK,eAAe,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;AACxE,KAAK,QAAQ,GAAG,CACd,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,eAAe,KACtB,MAAM,CAAC;AAOZ,eAAO,MAAM,KAAK;;;;;gBAKJ,MAAM;;CAElB,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC;AAEjC,wBAAgB,QAAQ,IAAI,KAAK,CAEhC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { DimensionValue, ImageSourcePropType, StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
export type ToastType = 'success' | 'error' | 'warning' | 'info';
|
|
3
|
+
export type ToastPosition = 'top' | 'bottom';
|
|
4
|
+
export type ToastTheme = 'light' | 'dark' | 'system';
|
|
5
|
+
export type ToastVariant = 'default' | 'tinted' | 'filled';
|
|
6
|
+
export type ToastImagePosition = 'left' | 'right';
|
|
7
|
+
/**
|
|
8
|
+
* Look & behaviour options. Every one of these can be set globally on
|
|
9
|
+
* <ToastProvider> and overridden per toast.
|
|
10
|
+
*/
|
|
11
|
+
export interface ToastAppearance {
|
|
12
|
+
position?: ToastPosition;
|
|
13
|
+
/** Milliseconds before auto-hide. 0 = stays until dismissed. */
|
|
14
|
+
duration?: number;
|
|
15
|
+
/** Thin countdown bar at the bottom. Default: false. */
|
|
16
|
+
showProgress?: boolean;
|
|
17
|
+
/** Master switch for swipe-to-dismiss. `false` turns off every direction. Default: true. */
|
|
18
|
+
swipeable?: boolean;
|
|
19
|
+
/** Swipe left to dismiss. Default: true. */
|
|
20
|
+
swipeLeft?: boolean;
|
|
21
|
+
/** Swipe right to dismiss. Default: true. */
|
|
22
|
+
swipeRight?: boolean;
|
|
23
|
+
/** Swipe up to dismiss. Default: true for top toasts, false for bottom toasts. */
|
|
24
|
+
swipeUp?: boolean;
|
|
25
|
+
/** Swipe down to dismiss. Default: true for bottom toasts, false for top toasts. */
|
|
26
|
+
swipeDown?: boolean;
|
|
27
|
+
/** Show the success/error/warning/info icon. Default: true. */
|
|
28
|
+
showIcon?: boolean;
|
|
29
|
+
/** Small type badge on the corner of a left image / app icon. Default: true. */
|
|
30
|
+
showTypeBadge?: boolean;
|
|
31
|
+
/** Colored stripe on the left edge. Default: shown automatically when there is no left icon. */
|
|
32
|
+
showAccentBar?: boolean;
|
|
33
|
+
/** Where `image` goes. Default: 'right'. */
|
|
34
|
+
imagePosition?: ToastImagePosition;
|
|
35
|
+
/** App icon shown on the left (like a basic Android toast). Leave unset to hide. */
|
|
36
|
+
appIcon?: ImageSourcePropType;
|
|
37
|
+
/** 'default' = plain card, 'tinted' = soft type color, 'filled' = solid type color. */
|
|
38
|
+
variant?: ToastVariant;
|
|
39
|
+
backgroundColor?: string;
|
|
40
|
+
borderColor?: string;
|
|
41
|
+
titleColor?: string;
|
|
42
|
+
messageColor?: string;
|
|
43
|
+
/** Max lines for the title. Default 1. 0 = unlimited. */
|
|
44
|
+
titleLines?: number;
|
|
45
|
+
/** Max lines for the message. Default 3. 0 = unlimited. */
|
|
46
|
+
messageLines?: number;
|
|
47
|
+
width?: DimensionValue;
|
|
48
|
+
/** Default 560 so it looks right on tablets. */
|
|
49
|
+
maxWidth?: DimensionValue;
|
|
50
|
+
minHeight?: DimensionValue;
|
|
51
|
+
height?: DimensionValue;
|
|
52
|
+
/** Default 18. */
|
|
53
|
+
borderRadius?: number;
|
|
54
|
+
/** Left icon / app icon size. Default 40. */
|
|
55
|
+
iconSize?: number;
|
|
56
|
+
/** Right image size. Default 44. */
|
|
57
|
+
imageSize?: number;
|
|
58
|
+
style?: StyleProp<ViewStyle>;
|
|
59
|
+
titleStyle?: StyleProp<TextStyle>;
|
|
60
|
+
messageStyle?: StyleProp<TextStyle>;
|
|
61
|
+
}
|
|
62
|
+
export interface ToastOptions extends ToastAppearance {
|
|
63
|
+
/** Pass an existing id to update a toast in place (e.g. "Uploading…" → "Uploaded"). */
|
|
64
|
+
id?: string;
|
|
65
|
+
type?: ToastType;
|
|
66
|
+
title?: string;
|
|
67
|
+
message?: string;
|
|
68
|
+
/** Picture shown left or right (see imagePosition). */
|
|
69
|
+
image?: ImageSourcePropType;
|
|
70
|
+
/** Custom left icon (avatar, logo). Replaces the type icon for this toast. */
|
|
71
|
+
icon?: ImageSourcePropType;
|
|
72
|
+
/** Override the type color for this toast only. */
|
|
73
|
+
accentColor?: string;
|
|
74
|
+
onPress?: () => void;
|
|
75
|
+
onHide?: () => void;
|
|
76
|
+
}
|
|
77
|
+
export interface ToastConfig extends ToastAppearance {
|
|
78
|
+
/** Distance from the top edge. Tip: pass useSafeAreaInsets().top + 8. */
|
|
79
|
+
topOffset?: number;
|
|
80
|
+
bottomOffset?: number;
|
|
81
|
+
theme?: ToastTheme;
|
|
82
|
+
/** Type colors. */
|
|
83
|
+
colors?: Partial<Record<ToastType, string>>;
|
|
84
|
+
/** Default duration per type, e.g. { error: 6000 }. */
|
|
85
|
+
durations?: Partial<Record<ToastType, number>>;
|
|
86
|
+
}
|
|
87
|
+
/** @internal */
|
|
88
|
+
export interface ToastData extends ToastOptions {
|
|
89
|
+
id: string;
|
|
90
|
+
rev: number;
|
|
91
|
+
dismissing?: boolean;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,SAAS,EACT,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AACjE,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,CAAC;AAC7C,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AACrD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAC3D,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,4FAA4F;IAC5F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kFAAkF;IAClF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oFAAoF;IACpF,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gFAAgF;IAChF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gGAAgG;IAChG,aAAa,CAAC,EAAE,OAAO,C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AC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,mBAAmB;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5C,uDAAuD;IACvD,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;CAChD;AAED,gBAAgB;AAChB,MAAM,WAAW,SAAU,SAAQ,YAAY;IAC7C,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,77 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react-native-notitoast",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-notitoast",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Notification-style toast messages for React Native: success, error, warning and info toasts with images, app icon, variants and full customization. Zero dependencies, Expo ready.",
|
|
5
|
+
"main": "./lib/commonjs/index.js",
|
|
6
|
+
"module": "./lib/module/index.js",
|
|
7
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
8
|
+
"react-native": "./src/index.ts",
|
|
9
|
+
"source": "./src/index.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"lib",
|
|
13
|
+
"!**/__tests__",
|
|
14
|
+
"!**/*.test.*"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
18
|
+
"build": "bob build",
|
|
19
|
+
"prepare": "bob build",
|
|
20
|
+
"release": "npm publish --access public"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"react-native",
|
|
24
|
+
"toast",
|
|
25
|
+
"react-native-toast",
|
|
26
|
+
"toast-message",
|
|
27
|
+
"notification",
|
|
28
|
+
"in-app-notification",
|
|
29
|
+
"notification-banner",
|
|
30
|
+
"snackbar",
|
|
31
|
+
"alert",
|
|
32
|
+
"banner",
|
|
33
|
+
"expo",
|
|
34
|
+
"expo-go",
|
|
35
|
+
"ios",
|
|
36
|
+
"android",
|
|
37
|
+
"typescript",
|
|
38
|
+
"customizable",
|
|
39
|
+
"success-toast",
|
|
40
|
+
"error-toast"
|
|
41
|
+
],
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"author": "Vasanthakumar A <2002vasanthakumar@gmail.com>",
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/vasanthakumar2k/react-native-notitoast.git"
|
|
47
|
+
},
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/vasanthakumar2k/react-native-notitoast/issues"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://github.com/vasanthakumar2k/react-native-notitoast#readme",
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"react": ">=18.0.0",
|
|
54
|
+
"react-native": ">=0.72.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@types/react": "^19.3.0",
|
|
58
|
+
"react": "^19.3.1",
|
|
59
|
+
"react-native": "^0.88.1",
|
|
60
|
+
"react-native-builder-bob": "^0.44.1",
|
|
61
|
+
"typescript": "^7.0.2"
|
|
62
|
+
},
|
|
63
|
+
"react-native-builder-bob": {
|
|
64
|
+
"source": "src",
|
|
65
|
+
"output": "lib",
|
|
66
|
+
"targets": [
|
|
67
|
+
"commonjs",
|
|
68
|
+
"module",
|
|
69
|
+
[
|
|
70
|
+
"typescript",
|
|
71
|
+
{
|
|
72
|
+
"project": "tsconfig.build.json"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
}
|