@dropi/react-native-design-system 0.1.25 → 0.2.1
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/lib/molecules/Toasts/FeedbackToast/FeedbackToast.d.ts +11 -0
- package/lib/molecules/Toasts/FeedbackToast/FeedbackToast.js +136 -0
- package/lib/molecules/Toasts/FeedbackToast/index.d.ts +1 -0
- package/lib/molecules/Toasts/FeedbackToast/index.js +16 -0
- package/lib/molecules/Toasts/index.d.ts +1 -0
- package/lib/molecules/Toasts/index.js +16 -0
- package/lib/molecules/index.d.ts +1 -0
- package/lib/molecules/index.js +11 -0
- package/lib/utils/DeviceInfo.d.ts +1 -0
- package/lib/utils/DeviceInfo.js +5 -2
- package/package.json +7 -3
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ToastTypes = 'success' | 'error' | 'warning' | 'info';
|
|
2
|
+
export type ToastConfig = {
|
|
3
|
+
type: ToastTypes;
|
|
4
|
+
title?: string;
|
|
5
|
+
message?: string;
|
|
6
|
+
setShowToast: (show: boolean) => void;
|
|
7
|
+
};
|
|
8
|
+
export type ToastRef = {
|
|
9
|
+
animateOut: () => void;
|
|
10
|
+
};
|
|
11
|
+
export declare const FeedbackToast: import("react").ForwardRefExoticComponent<ToastConfig & import("react").RefAttributes<ToastRef>>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FeedbackToast = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _lottieReactNative = _interopRequireDefault(require("lottie-react-native"));
|
|
10
|
+
var _utils = require("../../../utils");
|
|
11
|
+
var _constants = require("../../../constants");
|
|
12
|
+
var _atoms = require("../../../atoms");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
const FeedbackToast = exports.FeedbackToast = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
16
|
+
type,
|
|
17
|
+
title,
|
|
18
|
+
message,
|
|
19
|
+
setShowToast
|
|
20
|
+
}, ref) => {
|
|
21
|
+
const slideAnim = (0, _react.useRef)(new _reactNative.Animated.Value(-100)).current;
|
|
22
|
+
const [isAnimating, setIsAnimating] = (0, _react.useState)(false);
|
|
23
|
+
const animation = (0, _react.useRef)(null);
|
|
24
|
+
const closeToast = () => {
|
|
25
|
+
if (isAnimating) return;
|
|
26
|
+
setIsAnimating(true);
|
|
27
|
+
_reactNative.Animated.timing(slideAnim, {
|
|
28
|
+
toValue: -100,
|
|
29
|
+
duration: 400,
|
|
30
|
+
useNativeDriver: false
|
|
31
|
+
}).start(() => {
|
|
32
|
+
setIsAnimating(false);
|
|
33
|
+
setShowToast(false);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
(0, _react.useEffect)(() => {
|
|
37
|
+
// playSound()
|
|
38
|
+
_reactNative.Animated.sequence([_reactNative.Animated.timing(slideAnim, {
|
|
39
|
+
toValue: _reactNative.Platform.OS === 'ios' ? 100 : 50 + _utils.statusBarHeight,
|
|
40
|
+
duration: 300,
|
|
41
|
+
useNativeDriver: false
|
|
42
|
+
}), _reactNative.Animated.timing(slideAnim, {
|
|
43
|
+
toValue: _reactNative.Platform.OS === 'ios' ? 80 : 30 + _utils.statusBarHeight,
|
|
44
|
+
duration: 120,
|
|
45
|
+
useNativeDriver: false
|
|
46
|
+
})]).start();
|
|
47
|
+
}, []);
|
|
48
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
49
|
+
animateOut: closeToast
|
|
50
|
+
}));
|
|
51
|
+
const lottieFile = type === 'success' ? require('../../../../assets/lottie/afirmacion.json') : type === 'error' ? require('../../../../assets/lottie/buscando.json') : type === 'warning' ? require('../../../../assets/lottie/alerta.json') : require('../../../../assets/lottie/pregunta.json');
|
|
52
|
+
const bandColor = type === 'success' ? _constants.colors['Success-500'].light : type === 'error' ? _constants.colors['Error-500'].light : type === 'warning' ? _constants.colors['Warning-500'].light : _constants.colors['Info-500'].light;
|
|
53
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Animated.View, {
|
|
54
|
+
style: [styles.toastContainer, {
|
|
55
|
+
top: slideAnim
|
|
56
|
+
}],
|
|
57
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
58
|
+
style: {
|
|
59
|
+
backgroundColor: bandColor,
|
|
60
|
+
height: '100%',
|
|
61
|
+
width: 12,
|
|
62
|
+
borderTopLeftRadius: _constants.radius['border-2'],
|
|
63
|
+
borderBottomLeftRadius: _constants.radius['border-2']
|
|
64
|
+
}
|
|
65
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
66
|
+
style: {
|
|
67
|
+
paddingVertical: _constants.spacing['size-4']
|
|
68
|
+
},
|
|
69
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_lottieReactNative.default, {
|
|
70
|
+
autoPlay: true,
|
|
71
|
+
ref: animation,
|
|
72
|
+
style: {
|
|
73
|
+
width: !_utils.isTablet ? 60 : 80,
|
|
74
|
+
height: !_utils.isTablet ? 60 : 80,
|
|
75
|
+
backgroundColor: '#fff',
|
|
76
|
+
marginHorizontal: _constants.spacing['size-4']
|
|
77
|
+
},
|
|
78
|
+
source: lottieFile
|
|
79
|
+
})
|
|
80
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
81
|
+
style: {
|
|
82
|
+
flexDirection: 'row',
|
|
83
|
+
flex: 1,
|
|
84
|
+
paddingVertical: _constants.spacing['size-4']
|
|
85
|
+
},
|
|
86
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
87
|
+
style: {
|
|
88
|
+
flexShrink: 1,
|
|
89
|
+
marginRight: _constants.spacing['size-4']
|
|
90
|
+
},
|
|
91
|
+
children: [title && /*#__PURE__*/(0, _jsxRuntime.jsx)(_atoms.Heading, {
|
|
92
|
+
type: "h5",
|
|
93
|
+
style: {
|
|
94
|
+
color: _constants.colors['Gray-700'].light
|
|
95
|
+
},
|
|
96
|
+
children: title
|
|
97
|
+
}), message && /*#__PURE__*/(0, _jsxRuntime.jsx)(_atoms.Body, {
|
|
98
|
+
type: "m-regular",
|
|
99
|
+
style: {
|
|
100
|
+
marginTop: _constants.spacing['size-1'],
|
|
101
|
+
color: _constants.colors['Gray-600'].light
|
|
102
|
+
},
|
|
103
|
+
children: message
|
|
104
|
+
})]
|
|
105
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_atoms.TextButton, {
|
|
106
|
+
label: "",
|
|
107
|
+
variant: "secondary",
|
|
108
|
+
size: "large",
|
|
109
|
+
postIcon: "close-large",
|
|
110
|
+
onPress: closeToast
|
|
111
|
+
})]
|
|
112
|
+
})]
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
const styles = _reactNative.StyleSheet.create({
|
|
116
|
+
toastContainer: {
|
|
117
|
+
position: 'absolute',
|
|
118
|
+
zIndex: 99,
|
|
119
|
+
backgroundColor: '#fff',
|
|
120
|
+
width: _utils.windowWidth - 32,
|
|
121
|
+
maxWidth: 700,
|
|
122
|
+
flexDirection: 'row',
|
|
123
|
+
justifyContent: 'space-between',
|
|
124
|
+
paddingRight: _constants.spacing['size-5'],
|
|
125
|
+
borderRadius: _constants.radius['border-2'],
|
|
126
|
+
shadowColor: "#000",
|
|
127
|
+
shadowOffset: {
|
|
128
|
+
width: 0,
|
|
129
|
+
height: 2
|
|
130
|
+
},
|
|
131
|
+
shadowOpacity: 0.25,
|
|
132
|
+
shadowRadius: _constants.radius['border-1'],
|
|
133
|
+
elevation: 5,
|
|
134
|
+
alignSelf: 'center'
|
|
135
|
+
}
|
|
136
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FeedbackToast';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _FeedbackToast = require("./FeedbackToast");
|
|
7
|
+
Object.keys(_FeedbackToast).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _FeedbackToast[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _FeedbackToast[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FeedbackToast';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _FeedbackToast = require("./FeedbackToast");
|
|
7
|
+
Object.keys(_FeedbackToast).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _FeedbackToast[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _FeedbackToast[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
package/lib/molecules/index.d.ts
CHANGED
package/lib/molecules/index.js
CHANGED
|
@@ -57,4 +57,15 @@ Object.keys(_Tooltip).forEach(function (key) {
|
|
|
57
57
|
return _Tooltip[key];
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
+
});
|
|
61
|
+
var _Toasts = require("./Toasts");
|
|
62
|
+
Object.keys(_Toasts).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _Toasts[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _Toasts[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
60
71
|
});
|
package/lib/utils/DeviceInfo.js
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.windowWidth = exports.isTablet = void 0;
|
|
6
|
+
exports.windowWidth = exports.statusBarHeight = exports.isTablet = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
|
+
var _expoConstants = _interopRequireDefault(require("expo-constants"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
10
|
const windowWidth = exports.windowWidth = _reactNative.Dimensions.get("window").width;
|
|
9
|
-
const isTablet = exports.isTablet = windowWidth >= 768;
|
|
11
|
+
const isTablet = exports.isTablet = windowWidth >= 768;
|
|
12
|
+
const statusBarHeight = exports.statusBarHeight = _expoConstants.default.statusBarHeight;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dropi/react-native-design-system",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A React Native package built from scratch",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
"react": ">=19.0.0",
|
|
23
23
|
"react-native": ">=0.79.5",
|
|
24
24
|
"dropi-lib-icons": ">=1.2.5",
|
|
25
|
-
"expo-image": ">=2.4.0"
|
|
25
|
+
"expo-image": ">=2.4.0",
|
|
26
|
+
"lottie-react-native": ">=7.2.2",
|
|
27
|
+
"expo-constants": ">=17.1.7"
|
|
26
28
|
},
|
|
27
29
|
"devDependencies": {
|
|
28
30
|
"@babel/cli": "^7.28.3",
|
|
@@ -35,6 +37,8 @@
|
|
|
35
37
|
"react-native": "^0.82.1",
|
|
36
38
|
"typescript": "^5.6.0",
|
|
37
39
|
"dropi-lib-icons": "^1.2.5",
|
|
38
|
-
"expo-image": ">=2.4.0"
|
|
40
|
+
"expo-image": ">=2.4.0",
|
|
41
|
+
"lottie-react-native": ">=7.2.2",
|
|
42
|
+
"expo-constants": ">=17.1.7"
|
|
39
43
|
}
|
|
40
44
|
}
|