@synonymdev/react-native-toast 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +210 -0
- package/DEVELOPMENT.md +35 -0
- package/README.md +62 -0
- package/SynonymReactNativeToast.podspec +17 -0
- package/android/build.gradle +24 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/synonymdev/reactnativetoast/NativeToastModule.kt +332 -0
- package/android/src/main/java/com/synonymdev/reactnativetoast/NativeToastPackage.kt +15 -0
- package/ios/NativeToast.m +530 -0
- package/lib/commonjs/defaults.js +105 -0
- package/lib/commonjs/defaults.js.map +1 -0
- package/lib/commonjs/index.js +25 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/nativeModule.js +15 -0
- package/lib/commonjs/nativeModule.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/defaults.js +97 -0
- package/lib/module/defaults.js.map +1 -0
- package/lib/module/index.js +9 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/nativeModule.js +10 -0
- package/lib/module/nativeModule.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/commonjs/defaults.d.ts +9 -0
- package/lib/typescript/commonjs/defaults.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +6 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/nativeModule.d.ts +3 -0
- package/lib/typescript/commonjs/nativeModule.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/types.d.ts +57 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/module/defaults.d.ts +9 -0
- package/lib/typescript/module/defaults.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +6 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/nativeModule.d.ts +3 -0
- package/lib/typescript/module/nativeModule.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/types.d.ts +57 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/package.json +68 -0
- package/src/defaults.ts +110 -0
- package/src/index.ts +25 -0
- package/src/nativeModule.ts +12 -0
- package/src/types.ts +87 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const defaultToastStyle = {
|
|
4
|
+
backgroundColor: '#333333',
|
|
5
|
+
borderRadius: 14,
|
|
6
|
+
borderColor: '#444444',
|
|
7
|
+
borderWidth: 1,
|
|
8
|
+
shadowColor: '#05050A',
|
|
9
|
+
shadowOpacity: 0.5,
|
|
10
|
+
shadowRadius: 15,
|
|
11
|
+
shadowOffsetX: 0,
|
|
12
|
+
shadowOffsetY: 10,
|
|
13
|
+
shadowElevation: 10,
|
|
14
|
+
animation: 'slide-fade',
|
|
15
|
+
animationDurationMs: 200,
|
|
16
|
+
marginHorizontal: 24,
|
|
17
|
+
paddingHorizontal: 20,
|
|
18
|
+
paddingVertical: 16,
|
|
19
|
+
titleColor: '#EEEEF6',
|
|
20
|
+
titleFontSize: 14,
|
|
21
|
+
titleFontWeight: 'bold',
|
|
22
|
+
descriptionColor: '#D4D4DB',
|
|
23
|
+
descriptionFontSize: 14,
|
|
24
|
+
descriptionFontWeight: 'normal'
|
|
25
|
+
};
|
|
26
|
+
const variantStyles = {
|
|
27
|
+
success: {
|
|
28
|
+
backgroundColor: '#166534',
|
|
29
|
+
borderColor: '#22C55E'
|
|
30
|
+
},
|
|
31
|
+
info: {
|
|
32
|
+
backgroundColor: '#1D4ED8',
|
|
33
|
+
borderColor: '#60A5FA'
|
|
34
|
+
},
|
|
35
|
+
warning: {
|
|
36
|
+
backgroundColor: '#B45309',
|
|
37
|
+
borderColor: '#FBBF24'
|
|
38
|
+
},
|
|
39
|
+
error: {
|
|
40
|
+
backgroundColor: '#B91C1C',
|
|
41
|
+
borderColor: '#F87171'
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
let toastConfig = {};
|
|
45
|
+
export const configureToast = config => {
|
|
46
|
+
toastConfig = {
|
|
47
|
+
defaults: {
|
|
48
|
+
...toastConfig.defaults,
|
|
49
|
+
...config.defaults
|
|
50
|
+
},
|
|
51
|
+
options: {
|
|
52
|
+
...toastConfig.options,
|
|
53
|
+
...config.options
|
|
54
|
+
},
|
|
55
|
+
variants: {
|
|
56
|
+
...toastConfig.variants,
|
|
57
|
+
success: {
|
|
58
|
+
...toastConfig.variants?.success,
|
|
59
|
+
...config.variants?.success
|
|
60
|
+
},
|
|
61
|
+
info: {
|
|
62
|
+
...toastConfig.variants?.info,
|
|
63
|
+
...config.variants?.info
|
|
64
|
+
},
|
|
65
|
+
warning: {
|
|
66
|
+
...toastConfig.variants?.warning,
|
|
67
|
+
...config.variants?.warning
|
|
68
|
+
},
|
|
69
|
+
error: {
|
|
70
|
+
...toastConfig.variants?.error,
|
|
71
|
+
...config.variants?.error
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export const resetToastConfig = () => {
|
|
77
|
+
toastConfig = {};
|
|
78
|
+
};
|
|
79
|
+
export const resolveToastStyle = ({
|
|
80
|
+
type,
|
|
81
|
+
style
|
|
82
|
+
}) => ({
|
|
83
|
+
...defaultToastStyle,
|
|
84
|
+
...toastConfig.defaults,
|
|
85
|
+
...variantStyles[type],
|
|
86
|
+
...toastConfig.variants?.[type],
|
|
87
|
+
...style
|
|
88
|
+
});
|
|
89
|
+
export const resolveToastOptions = options => ({
|
|
90
|
+
...toastConfig.options,
|
|
91
|
+
...options,
|
|
92
|
+
style: resolveToastStyle({
|
|
93
|
+
type: options.type,
|
|
94
|
+
style: options.style
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["defaultToastStyle","backgroundColor","borderRadius","borderColor","borderWidth","shadowColor","shadowOpacity","shadowRadius","shadowOffsetX","shadowOffsetY","shadowElevation","animation","animationDurationMs","marginHorizontal","paddingHorizontal","paddingVertical","titleColor","titleFontSize","titleFontWeight","descriptionColor","descriptionFontSize","descriptionFontWeight","variantStyles","success","info","warning","error","toastConfig","configureToast","config","defaults","options","variants","resetToastConfig","resolveToastStyle","type","style","resolveToastOptions"],"sourceRoot":"../../src","sources":["defaults.ts"],"mappings":";;AAOA,MAAMA,iBAAmC,GAAG;EAC3CC,eAAe,EAAE,SAAS;EAC1BC,YAAY,EAAE,EAAE;EAChBC,WAAW,EAAE,SAAS;EACtBC,WAAW,EAAE,CAAC;EACdC,WAAW,EAAE,SAAS;EACtBC,aAAa,EAAE,GAAG;EAClBC,YAAY,EAAE,EAAE;EAChBC,aAAa,EAAE,CAAC;EAChBC,aAAa,EAAE,EAAE;EACjBC,eAAe,EAAE,EAAE;EACnBC,SAAS,EAAE,YAAY;EACvBC,mBAAmB,EAAE,GAAG;EACxBC,gBAAgB,EAAE,EAAE;EACpBC,iBAAiB,EAAE,EAAE;EACrBC,eAAe,EAAE,EAAE;EACnBC,UAAU,EAAE,SAAS;EACrBC,aAAa,EAAE,EAAE;EACjBC,eAAe,EAAE,MAAM;EACvBC,gBAAgB,EAAE,SAAS;EAC3BC,mBAAmB,EAAE,EAAE;EACvBC,qBAAqB,EAAE;AACxB,CAAC;AAED,MAAMC,aAA2D,GAAG;EACnEC,OAAO,EAAE;IACRtB,eAAe,EAAE,SAAS;IAC1BE,WAAW,EAAE;EACd,CAAC;EACDqB,IAAI,EAAE;IACLvB,eAAe,EAAE,SAA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AAa,CAACa,IAAI,CAAC;EACtB,GAAGR,WAAW,CAACK,QAAQ,GAAGG,IAAI,CAAC;EAC/B,GAAGC;AACJ,CAAC,CAAC;AAEF,OAAO,MAAMC,mBAAmB,GAAIN,OAAqB,KAAoB;EAC5E,GAAGJ,WAAW,CAACI,OAAO;EACtB,GAAGA,OAAO;EACVK,KAAK,EAAEF,iBAAiB,CAAC;IACxBC,IAAI,EAAEJ,OAAO,CAACI,IAAI;IAClBC,KAAK,EAAEL,OAAO,CAACK;EAChB,CAAC;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { configureToast, resetToastConfig, resolveToastOptions } from "./defaults.js";
|
|
4
|
+
import { showRawNativeToast } from "./nativeModule.js";
|
|
5
|
+
export { configureToast, resetToastConfig };
|
|
6
|
+
export const showToast = options => {
|
|
7
|
+
showRawNativeToast(resolveToastOptions(options));
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["configureToast","resetToastConfig","resolveToastOptions","showRawNativeToast","showToast","options"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SACCA,cAAc,EACdC,gBAAgB,EAChBC,mBAAmB,QACb,eAAY;AACnB,SAASC,kBAAkB,QAAQ,mBAAgB;AAenD,SAASH,cAAc,EAAEC,gBAAgB;AAEzC,OAAO,MAAMG,SAAS,GAAIC,OAAqB,IAAW;EACzDF,kBAAkB,CAACD,mBAAmB,CAACG,OAAO,CAAC,CAAC;AACjD,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeModules","NativeToast","showRawNativeToast","options","show"],"sourceRoot":"../../src","sources":["nativeModule.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,cAAc;AAO5C,MAAM;EAAEC;AAAY,CAAC,GAAGD,aAAoD;AAE5E,OAAO,MAAME,kBAAkB,GAAIC,OAAqB,IAAW;EAClEF,WAAW,EAAEG,IAAI,CAACD,OAAO,CAAC;AAC3B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NativeToastConfig, NativeToastStyle, NativeToastVariant, ToastOptions } from './types';
|
|
2
|
+
export declare const configureToast: (config: NativeToastConfig) => void;
|
|
3
|
+
export declare const resetToastConfig: () => void;
|
|
4
|
+
export declare const resolveToastStyle: ({ type, style, }: {
|
|
5
|
+
type: NativeToastVariant;
|
|
6
|
+
style?: NativeToastStyle;
|
|
7
|
+
}) => NativeToastStyle;
|
|
8
|
+
export declare const resolveToastOptions: (options: ToastOptions) => ToastOptions;
|
|
9
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../src/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,MAAM,SAAS,CAAC;AA+CjB,eAAO,MAAM,cAAc,GAAI,QAAQ,iBAAiB,KAAG,IA8B1D,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAO,IAEnC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,kBAG/B;IACF,IAAI,EAAE,kBAAkB,CAAC;IACzB,KAAK,CAAC,EAAE,gBAAgB,CAAC;CACzB,KAAG,gBAMF,CAAC;AAEH,eAAO,MAAM,mBAAmB,GAAI,SAAS,YAAY,KAAG,YAO1D,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { configureToast, resetToastConfig } from './defaults';
|
|
2
|
+
import type { ToastOptions } from './types';
|
|
3
|
+
export type { NativeToastAnimation, NativeToastBlurEffect, NativeToastConfig, NativeToastDefaultOptions, NativeToastFontWeight, NativeToastStyle, NativeToastVariantStyles, NativeToastVariant, ToastOptions, } from './types';
|
|
4
|
+
export { configureToast, resetToastConfig };
|
|
5
|
+
export declare const showToast: (options: ToastOptions) => void;
|
|
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,EACN,cAAc,EACd,gBAAgB,EAEhB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,YAAY,EACX,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,YAAY,GACZ,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;AAE5C,eAAO,MAAM,SAAS,GAAI,SAAS,YAAY,KAAG,IAEjD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeModule.d.ts","sourceRoot":"","sources":["../../../src/nativeModule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQ5C,eAAO,MAAM,kBAAkB,GAAI,SAAS,YAAY,KAAG,IAE1D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type NativeToastVariant = 'success' | 'info' | 'warning' | 'error';
|
|
2
|
+
export type NativeToastAnimation = 'none' | 'fade' | 'slide' | 'slide-fade';
|
|
3
|
+
export type NativeToastFontWeight = 'normal' | 'medium' | 'semibold' | 'bold';
|
|
4
|
+
export type NativeToastBlurEffect = 'none' | 'extraLight' | 'light' | 'dark' | 'regular' | 'prominent' | 'systemUltraThinMaterial' | 'systemThinMaterial' | 'systemMaterial' | 'systemThickMaterial' | 'systemChromeMaterial' | 'systemUltraThinMaterialLight' | 'systemThinMaterialLight' | 'systemMaterialLight' | 'systemThickMaterialLight' | 'systemChromeMaterialLight' | 'systemUltraThinMaterialDark' | 'systemThinMaterialDark' | 'systemMaterialDark' | 'systemThickMaterialDark' | 'systemChromeMaterialDark';
|
|
5
|
+
export type NativeToastStyle = {
|
|
6
|
+
backgroundColor?: string;
|
|
7
|
+
iosBlurEffect?: NativeToastBlurEffect;
|
|
8
|
+
iosBlurAmount?: number;
|
|
9
|
+
iosBlurTintOpacity?: number;
|
|
10
|
+
borderRadius?: number;
|
|
11
|
+
borderColor?: string;
|
|
12
|
+
borderWidth?: number;
|
|
13
|
+
shadowColor?: string;
|
|
14
|
+
shadowOpacity?: number;
|
|
15
|
+
shadowRadius?: number;
|
|
16
|
+
shadowOffsetX?: number;
|
|
17
|
+
shadowOffsetY?: number;
|
|
18
|
+
shadowElevation?: number;
|
|
19
|
+
animation?: NativeToastAnimation;
|
|
20
|
+
animationDurationMs?: number;
|
|
21
|
+
width?: number;
|
|
22
|
+
maxWidth?: number;
|
|
23
|
+
marginHorizontal?: number;
|
|
24
|
+
padding?: number;
|
|
25
|
+
paddingHorizontal?: number;
|
|
26
|
+
paddingVertical?: number;
|
|
27
|
+
paddingTop?: number;
|
|
28
|
+
paddingRight?: number;
|
|
29
|
+
paddingBottom?: number;
|
|
30
|
+
paddingLeft?: number;
|
|
31
|
+
titleColor?: string;
|
|
32
|
+
titleFontFamily?: string;
|
|
33
|
+
titleFontSize?: number;
|
|
34
|
+
titleFontWeight?: NativeToastFontWeight;
|
|
35
|
+
descriptionColor?: string;
|
|
36
|
+
descriptionFontFamily?: string;
|
|
37
|
+
descriptionFontSize?: number;
|
|
38
|
+
descriptionFontWeight?: NativeToastFontWeight;
|
|
39
|
+
};
|
|
40
|
+
export type NativeToastVariantStyles = Partial<Record<NativeToastVariant, NativeToastStyle>>;
|
|
41
|
+
export type ToastOptions = {
|
|
42
|
+
type: NativeToastVariant;
|
|
43
|
+
title: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
autoHide?: boolean;
|
|
46
|
+
dismissible?: boolean;
|
|
47
|
+
haptics?: boolean;
|
|
48
|
+
durationMs?: number;
|
|
49
|
+
style?: NativeToastStyle;
|
|
50
|
+
};
|
|
51
|
+
export type NativeToastDefaultOptions = Pick<ToastOptions, 'autoHide' | 'dismissible' | 'haptics' | 'durationMs'>;
|
|
52
|
+
export type NativeToastConfig = {
|
|
53
|
+
defaults?: NativeToastStyle;
|
|
54
|
+
variants?: NativeToastVariantStyles;
|
|
55
|
+
options?: NativeToastDefaultOptions;
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAC1E,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC;AAC5E,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;AAC9E,MAAM,MAAM,qBAAqB,GAC9B,MAAM,GACN,YAAY,GACZ,OAAO,GACP,MAAM,GACN,SAAS,GACT,WAAW,GACX,yBAAyB,GACzB,oBAAoB,GACpB,gBAAgB,GAChB,qBAAqB,GACrB,sBAAsB,GACtB,8BAA8B,GAC9B,yBAAyB,GACzB,qBAAqB,GACrB,0BAA0B,GAC1B,2BAA2B,GAC3B,6BAA6B,GAC7B,wBAAwB,GACxB,oBAAoB,GACpB,yBAAyB,GACzB,0BAA0B,CAAC;AAE9B,MAAM,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AE,qBAAqB,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC7C,MAAM,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAC5C,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,kBAAkB,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC3C,YAAY,EACZ,UAAU,GAAG,aAAa,GAAG,SAAS,GAAG,YAAY,CACrD,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,QAAQ,CAAC,EAAE,wBAAwB,CAAC;IACpC,OAAO,CAAC,EAAE,yBAAyB,CAAC;CACpC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NativeToastConfig, NativeToastStyle, NativeToastVariant, ToastOptions } from './types.js';
|
|
2
|
+
export declare const configureToast: (config: NativeToastConfig) => void;
|
|
3
|
+
export declare const resetToastConfig: () => void;
|
|
4
|
+
export declare const resolveToastStyle: ({ type, style, }: {
|
|
5
|
+
type: NativeToastVariant;
|
|
6
|
+
style?: NativeToastStyle;
|
|
7
|
+
}) => NativeToastStyle;
|
|
8
|
+
export declare const resolveToastOptions: (options: ToastOptions) => ToastOptions;
|
|
9
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../src/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,MAAM,YAAS,CAAC;AA+CjB,eAAO,MAAM,cAAc,GAAI,QAAQ,iBAAiB,KAAG,IA8B1D,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAO,IAEnC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,kBAG/B;IACF,IAAI,EAAE,kBAAkB,CAAC;IACzB,KAAK,CAAC,EAAE,gBAAgB,CAAC;CACzB,KAAG,gBAMF,CAAC;AAEH,eAAO,MAAM,mBAAmB,GAAI,SAAS,YAAY,KAAG,YAO1D,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { configureToast, resetToastConfig } from './defaults.js';
|
|
2
|
+
import type { ToastOptions } from './types.js';
|
|
3
|
+
export type { NativeToastAnimation, NativeToastBlurEffect, NativeToastConfig, NativeToastDefaultOptions, NativeToastFontWeight, NativeToastStyle, NativeToastVariantStyles, NativeToastVariant, ToastOptions, } from './types.js';
|
|
4
|
+
export { configureToast, resetToastConfig };
|
|
5
|
+
export declare const showToast: (options: ToastOptions) => void;
|
|
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,EACN,cAAc,EACd,gBAAgB,EAEhB,MAAM,eAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAS,CAAC;AAE5C,YAAY,EACX,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,YAAY,GACZ,MAAM,YAAS,CAAC;AAEjB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;AAE5C,eAAO,MAAM,SAAS,GAAI,SAAS,YAAY,KAAG,IAEjD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeModule.d.ts","sourceRoot":"","sources":["../../../src/nativeModule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAS,CAAC;AAQ5C,eAAO,MAAM,kBAAkB,GAAI,SAAS,YAAY,KAAG,IAE1D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type NativeToastVariant = 'success' | 'info' | 'warning' | 'error';
|
|
2
|
+
export type NativeToastAnimation = 'none' | 'fade' | 'slide' | 'slide-fade';
|
|
3
|
+
export type NativeToastFontWeight = 'normal' | 'medium' | 'semibold' | 'bold';
|
|
4
|
+
export type NativeToastBlurEffect = 'none' | 'extraLight' | 'light' | 'dark' | 'regular' | 'prominent' | 'systemUltraThinMaterial' | 'systemThinMaterial' | 'systemMaterial' | 'systemThickMaterial' | 'systemChromeMaterial' | 'systemUltraThinMaterialLight' | 'systemThinMaterialLight' | 'systemMaterialLight' | 'systemThickMaterialLight' | 'systemChromeMaterialLight' | 'systemUltraThinMaterialDark' | 'systemThinMaterialDark' | 'systemMaterialDark' | 'systemThickMaterialDark' | 'systemChromeMaterialDark';
|
|
5
|
+
export type NativeToastStyle = {
|
|
6
|
+
backgroundColor?: string;
|
|
7
|
+
iosBlurEffect?: NativeToastBlurEffect;
|
|
8
|
+
iosBlurAmount?: number;
|
|
9
|
+
iosBlurTintOpacity?: number;
|
|
10
|
+
borderRadius?: number;
|
|
11
|
+
borderColor?: string;
|
|
12
|
+
borderWidth?: number;
|
|
13
|
+
shadowColor?: string;
|
|
14
|
+
shadowOpacity?: number;
|
|
15
|
+
shadowRadius?: number;
|
|
16
|
+
shadowOffsetX?: number;
|
|
17
|
+
shadowOffsetY?: number;
|
|
18
|
+
shadowElevation?: number;
|
|
19
|
+
animation?: NativeToastAnimation;
|
|
20
|
+
animationDurationMs?: number;
|
|
21
|
+
width?: number;
|
|
22
|
+
maxWidth?: number;
|
|
23
|
+
marginHorizontal?: number;
|
|
24
|
+
padding?: number;
|
|
25
|
+
paddingHorizontal?: number;
|
|
26
|
+
paddingVertical?: number;
|
|
27
|
+
paddingTop?: number;
|
|
28
|
+
paddingRight?: number;
|
|
29
|
+
paddingBottom?: number;
|
|
30
|
+
paddingLeft?: number;
|
|
31
|
+
titleColor?: string;
|
|
32
|
+
titleFontFamily?: string;
|
|
33
|
+
titleFontSize?: number;
|
|
34
|
+
titleFontWeight?: NativeToastFontWeight;
|
|
35
|
+
descriptionColor?: string;
|
|
36
|
+
descriptionFontFamily?: string;
|
|
37
|
+
descriptionFontSize?: number;
|
|
38
|
+
descriptionFontWeight?: NativeToastFontWeight;
|
|
39
|
+
};
|
|
40
|
+
export type NativeToastVariantStyles = Partial<Record<NativeToastVariant, NativeToastStyle>>;
|
|
41
|
+
export type ToastOptions = {
|
|
42
|
+
type: NativeToastVariant;
|
|
43
|
+
title: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
autoHide?: boolean;
|
|
46
|
+
dismissible?: boolean;
|
|
47
|
+
haptics?: boolean;
|
|
48
|
+
durationMs?: number;
|
|
49
|
+
style?: NativeToastStyle;
|
|
50
|
+
};
|
|
51
|
+
export type NativeToastDefaultOptions = Pick<ToastOptions, 'autoHide' | 'dismissible' | 'haptics' | 'durationMs'>;
|
|
52
|
+
export type NativeToastConfig = {
|
|
53
|
+
defaults?: NativeToastStyle;
|
|
54
|
+
variants?: NativeToastVariantStyles;
|
|
55
|
+
options?: NativeToastDefaultOptions;
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAC1E,MAAM,MAAM,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
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@synonymdev/react-native-toast",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Native toast notifications for React Native",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react-native",
|
|
7
|
+
"toast",
|
|
8
|
+
"ios",
|
|
9
|
+
"android"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/synonymdev/react-native-toast#readme",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/synonymdev/react-native-toast.git"
|
|
15
|
+
},
|
|
16
|
+
"main": "./lib/commonjs/index.js",
|
|
17
|
+
"module": "./lib/module/index.js",
|
|
18
|
+
"types": "./lib/typescript/commonjs/index.d.ts",
|
|
19
|
+
"react-native": "src/index.ts",
|
|
20
|
+
"source": "src/index.ts",
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "bob build",
|
|
23
|
+
"clean": "node -e \"require('fs').rmSync('lib', { recursive: true, force: true })\"",
|
|
24
|
+
"prepack": "yarn clean && yarn build",
|
|
25
|
+
"test": "jest"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"react-native": "./src/index.ts",
|
|
30
|
+
"source": "./src/index.ts",
|
|
31
|
+
"import": {
|
|
32
|
+
"types": "./lib/typescript/module/index.d.ts",
|
|
33
|
+
"default": "./lib/module/index.js"
|
|
34
|
+
},
|
|
35
|
+
"require": {
|
|
36
|
+
"types": "./lib/typescript/commonjs/index.d.ts",
|
|
37
|
+
"default": "./lib/commonjs/index.js"
|
|
38
|
+
},
|
|
39
|
+
"default": "./lib/commonjs/index.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"android/build.gradle",
|
|
44
|
+
"android/src",
|
|
45
|
+
"API.md",
|
|
46
|
+
"DEVELOPMENT.md",
|
|
47
|
+
"ios",
|
|
48
|
+
"lib/commonjs",
|
|
49
|
+
"lib/module",
|
|
50
|
+
"lib/typescript",
|
|
51
|
+
"src",
|
|
52
|
+
"SynonymReactNativeToast.podspec"
|
|
53
|
+
],
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"react": "*",
|
|
56
|
+
"react-native": "*"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@react-native/babel-preset": "0.86.0",
|
|
60
|
+
"@types/jest": "^30.0.0",
|
|
61
|
+
"jest": "^30.4.2",
|
|
62
|
+
"react": "19.2.3",
|
|
63
|
+
"react-native": "0.86.0",
|
|
64
|
+
"react-native-builder-bob": "^0.43.0",
|
|
65
|
+
"typescript": "^5.8.3"
|
|
66
|
+
},
|
|
67
|
+
"license": "MIT"
|
|
68
|
+
}
|
package/src/defaults.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
NativeToastConfig,
|
|
3
|
+
NativeToastStyle,
|
|
4
|
+
NativeToastVariant,
|
|
5
|
+
ToastOptions,
|
|
6
|
+
} from './types';
|
|
7
|
+
|
|
8
|
+
const defaultToastStyle: NativeToastStyle = {
|
|
9
|
+
backgroundColor: '#333333',
|
|
10
|
+
borderRadius: 14,
|
|
11
|
+
borderColor: '#444444',
|
|
12
|
+
borderWidth: 1,
|
|
13
|
+
shadowColor: '#05050A',
|
|
14
|
+
shadowOpacity: 0.5,
|
|
15
|
+
shadowRadius: 15,
|
|
16
|
+
shadowOffsetX: 0,
|
|
17
|
+
shadowOffsetY: 10,
|
|
18
|
+
shadowElevation: 10,
|
|
19
|
+
animation: 'slide-fade',
|
|
20
|
+
animationDurationMs: 200,
|
|
21
|
+
marginHorizontal: 24,
|
|
22
|
+
paddingHorizontal: 20,
|
|
23
|
+
paddingVertical: 16,
|
|
24
|
+
titleColor: '#EEEEF6',
|
|
25
|
+
titleFontSize: 14,
|
|
26
|
+
titleFontWeight: 'bold',
|
|
27
|
+
descriptionColor: '#D4D4DB',
|
|
28
|
+
descriptionFontSize: 14,
|
|
29
|
+
descriptionFontWeight: 'normal',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const variantStyles: Record<NativeToastVariant, NativeToastStyle> = {
|
|
33
|
+
success: {
|
|
34
|
+
backgroundColor: '#166534',
|
|
35
|
+
borderColor: '#22C55E',
|
|
36
|
+
},
|
|
37
|
+
info: {
|
|
38
|
+
backgroundColor: '#1D4ED8',
|
|
39
|
+
borderColor: '#60A5FA',
|
|
40
|
+
},
|
|
41
|
+
warning: {
|
|
42
|
+
backgroundColor: '#B45309',
|
|
43
|
+
borderColor: '#FBBF24',
|
|
44
|
+
},
|
|
45
|
+
error: {
|
|
46
|
+
backgroundColor: '#B91C1C',
|
|
47
|
+
borderColor: '#F87171',
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
let toastConfig: NativeToastConfig = {};
|
|
52
|
+
|
|
53
|
+
export const configureToast = (config: NativeToastConfig): void => {
|
|
54
|
+
toastConfig = {
|
|
55
|
+
defaults: {
|
|
56
|
+
...toastConfig.defaults,
|
|
57
|
+
...config.defaults,
|
|
58
|
+
},
|
|
59
|
+
options: {
|
|
60
|
+
...toastConfig.options,
|
|
61
|
+
...config.options,
|
|
62
|
+
},
|
|
63
|
+
variants: {
|
|
64
|
+
...toastConfig.variants,
|
|
65
|
+
success: {
|
|
66
|
+
...toastConfig.variants?.success,
|
|
67
|
+
...config.variants?.success,
|
|
68
|
+
},
|
|
69
|
+
info: {
|
|
70
|
+
...toastConfig.variants?.info,
|
|
71
|
+
...config.variants?.info,
|
|
72
|
+
},
|
|
73
|
+
warning: {
|
|
74
|
+
...toastConfig.variants?.warning,
|
|
75
|
+
...config.variants?.warning,
|
|
76
|
+
},
|
|
77
|
+
error: {
|
|
78
|
+
...toastConfig.variants?.error,
|
|
79
|
+
...config.variants?.error,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const resetToastConfig = (): void => {
|
|
86
|
+
toastConfig = {};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const resolveToastStyle = ({
|
|
90
|
+
type,
|
|
91
|
+
style,
|
|
92
|
+
}: {
|
|
93
|
+
type: NativeToastVariant;
|
|
94
|
+
style?: NativeToastStyle;
|
|
95
|
+
}): NativeToastStyle => ({
|
|
96
|
+
...defaultToastStyle,
|
|
97
|
+
...toastConfig.defaults,
|
|
98
|
+
...variantStyles[type],
|
|
99
|
+
...toastConfig.variants?.[type],
|
|
100
|
+
...style,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export const resolveToastOptions = (options: ToastOptions): ToastOptions => ({
|
|
104
|
+
...toastConfig.options,
|
|
105
|
+
...options,
|
|
106
|
+
style: resolveToastStyle({
|
|
107
|
+
type: options.type,
|
|
108
|
+
style: options.style,
|
|
109
|
+
}),
|
|
110
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
configureToast,
|
|
3
|
+
resetToastConfig,
|
|
4
|
+
resolveToastOptions,
|
|
5
|
+
} from './defaults';
|
|
6
|
+
import { showRawNativeToast } from './nativeModule';
|
|
7
|
+
import type { ToastOptions } from './types';
|
|
8
|
+
|
|
9
|
+
export type {
|
|
10
|
+
NativeToastAnimation,
|
|
11
|
+
NativeToastBlurEffect,
|
|
12
|
+
NativeToastConfig,
|
|
13
|
+
NativeToastDefaultOptions,
|
|
14
|
+
NativeToastFontWeight,
|
|
15
|
+
NativeToastStyle,
|
|
16
|
+
NativeToastVariantStyles,
|
|
17
|
+
NativeToastVariant,
|
|
18
|
+
ToastOptions,
|
|
19
|
+
} from './types';
|
|
20
|
+
|
|
21
|
+
export { configureToast, resetToastConfig };
|
|
22
|
+
|
|
23
|
+
export const showToast = (options: ToastOptions): void => {
|
|
24
|
+
showRawNativeToast(resolveToastOptions(options));
|
|
25
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
|
+
import type { ToastOptions } from './types';
|
|
3
|
+
|
|
4
|
+
type NativeToastModule = {
|
|
5
|
+
show: (options: ToastOptions) => void;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const { NativeToast } = NativeModules as { NativeToast?: NativeToastModule };
|
|
9
|
+
|
|
10
|
+
export const showRawNativeToast = (options: ToastOptions): void => {
|
|
11
|
+
NativeToast?.show(options);
|
|
12
|
+
};
|