@dropi/react-native-design-system 0.3.18 → 0.3.20
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/atoms/Buttons/DefaultButton.d.ts +11 -5
- package/lib/atoms/Buttons/DefaultButton.js +95 -25
- package/lib/molecules/DialogModal/DialogModal.d.ts +2 -1
- package/lib/molecules/DialogModal/DialogModal.js +93 -19
- package/lib/molecules/Toasts/ToastProvider/ToastProvider.js +1 -16
- package/package.json +1 -1
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { TouchableOpacityProps } from
|
|
2
|
-
import { IconName } from
|
|
3
|
-
export type Variant =
|
|
4
|
-
type Size =
|
|
1
|
+
import { TouchableOpacityProps } from "react-native";
|
|
2
|
+
import { IconName } from "dropi-lib-icons";
|
|
3
|
+
export type Variant = "primary" | "secondary" | "tertiary" | "success" | "error" | "warning" | "info";
|
|
4
|
+
type Size = "small" | "normal" | "large";
|
|
5
|
+
type ButtonConfig = {
|
|
6
|
+
backgroundColor: string;
|
|
7
|
+
labelColor: string;
|
|
8
|
+
borderColor: string;
|
|
9
|
+
};
|
|
5
10
|
interface Props extends TouchableOpacityProps {
|
|
6
11
|
label: string;
|
|
7
12
|
variant: Variant;
|
|
@@ -10,6 +15,7 @@ interface Props extends TouchableOpacityProps {
|
|
|
10
15
|
postIcon?: IconName;
|
|
11
16
|
disabled?: boolean;
|
|
12
17
|
isMakingRequest?: boolean;
|
|
18
|
+
buttonConfig?: ButtonConfig;
|
|
13
19
|
}
|
|
14
|
-
export declare const DefaultButton: ({ label, variant, size, preIcon, postIcon, disabled, isMakingRequest, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare const DefaultButton: ({ label, variant, size, preIcon, postIcon, disabled, isMakingRequest, buttonConfig, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
15
21
|
export {};
|
|
@@ -18,55 +18,125 @@ const DefaultButton = ({
|
|
|
18
18
|
postIcon,
|
|
19
19
|
disabled,
|
|
20
20
|
isMakingRequest,
|
|
21
|
+
buttonConfig,
|
|
21
22
|
...rest
|
|
22
23
|
}) => {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const getTextVariant = () => {
|
|
25
|
+
if (size === "small") return "s";
|
|
26
|
+
if (size === "large") return "l";
|
|
27
|
+
return "m";
|
|
28
|
+
};
|
|
29
|
+
const getIconSize = () => {
|
|
30
|
+
if (size === "small") return 12;
|
|
31
|
+
if (size === "large") return 16;
|
|
32
|
+
return 14;
|
|
33
|
+
};
|
|
34
|
+
const getTabletIconSize = () => {
|
|
35
|
+
if (size === "small") return 20;
|
|
36
|
+
if (size === "large") return 24;
|
|
37
|
+
return 22;
|
|
38
|
+
};
|
|
39
|
+
const getButtonConfig = () => {
|
|
40
|
+
if (buttonConfig) {
|
|
41
|
+
return buttonConfig;
|
|
42
|
+
}
|
|
43
|
+
switch (variant) {
|
|
44
|
+
case "secondary":
|
|
45
|
+
return {
|
|
46
|
+
backgroundColor: "transparent",
|
|
47
|
+
labelColor: _constants.colors["Primary-500"].light,
|
|
48
|
+
borderColor: _constants.colors["Primary-500"].light
|
|
49
|
+
};
|
|
50
|
+
case "tertiary":
|
|
51
|
+
return {
|
|
52
|
+
backgroundColor: "transparent",
|
|
53
|
+
labelColor: _constants.colors["Gray-500"].light,
|
|
54
|
+
borderColor: _constants.colors["Gray-500"].light
|
|
55
|
+
};
|
|
56
|
+
case "success":
|
|
57
|
+
return {
|
|
58
|
+
backgroundColor: _constants.colors["Success-500"].light,
|
|
59
|
+
labelColor: _constants.colors.White.light,
|
|
60
|
+
borderColor: _constants.colors["Success-500"].light
|
|
61
|
+
};
|
|
62
|
+
case "error":
|
|
63
|
+
return {
|
|
64
|
+
backgroundColor: _constants.colors["Error-500"].light,
|
|
65
|
+
labelColor: _constants.colors.White.light,
|
|
66
|
+
borderColor: _constants.colors["Error-500"].light
|
|
67
|
+
};
|
|
68
|
+
case "warning":
|
|
69
|
+
return {
|
|
70
|
+
backgroundColor: _constants.colors["Warning-500"].light,
|
|
71
|
+
labelColor: _constants.colors.White.light,
|
|
72
|
+
borderColor: _constants.colors["Warning-500"].light
|
|
73
|
+
};
|
|
74
|
+
case "info":
|
|
75
|
+
return {
|
|
76
|
+
backgroundColor: _constants.colors["Info-500"].light,
|
|
77
|
+
labelColor: _constants.colors.White.light,
|
|
78
|
+
borderColor: _constants.colors["Info-500"].light
|
|
79
|
+
};
|
|
80
|
+
default:
|
|
81
|
+
// Primary variant
|
|
82
|
+
return {
|
|
83
|
+
backgroundColor: _constants.colors["Primary-500"].light,
|
|
84
|
+
labelColor: _constants.colors.White.light,
|
|
85
|
+
borderColor: _constants.colors["Primary-500"].light
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const getPaddingVertical = () => {
|
|
90
|
+
if (size === "small") return _constants.spacing["size-2"];
|
|
91
|
+
if (size === "large") return _constants.spacing["size-4"];
|
|
92
|
+
return _constants.spacing["size-3"];
|
|
93
|
+
};
|
|
94
|
+
const textVariant = getTextVariant();
|
|
95
|
+
const iconSize = getIconSize();
|
|
96
|
+
const tabletIconSize = getTabletIconSize();
|
|
97
|
+
const currentButtonConfig = getButtonConfig();
|
|
27
98
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
|
|
28
99
|
style: {
|
|
29
|
-
backgroundColor:
|
|
30
|
-
paddingVertical:
|
|
31
|
-
paddingHorizontal: _constants.spacing[
|
|
32
|
-
borderRadius: _constants.radius[
|
|
33
|
-
alignItems:
|
|
34
|
-
justifyContent:
|
|
100
|
+
backgroundColor: currentButtonConfig.backgroundColor,
|
|
101
|
+
paddingVertical: getPaddingVertical(),
|
|
102
|
+
paddingHorizontal: _constants.spacing["size-4"],
|
|
103
|
+
borderRadius: _constants.radius["border-2"],
|
|
104
|
+
alignItems: "center",
|
|
105
|
+
justifyContent: "center",
|
|
35
106
|
opacity: disabled ? 0.5 : 1,
|
|
36
|
-
borderWidth:
|
|
37
|
-
borderColor:
|
|
38
|
-
flexDirection:
|
|
107
|
+
borderWidth: 1,
|
|
108
|
+
borderColor: currentButtonConfig.borderColor,
|
|
109
|
+
flexDirection: "row"
|
|
39
110
|
},
|
|
40
111
|
disabled: disabled || isMakingRequest,
|
|
41
112
|
...rest,
|
|
42
113
|
children: [preIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
43
114
|
style: {
|
|
44
|
-
marginRight: _constants.spacing[
|
|
115
|
+
marginRight: _constants.spacing["size-2"]
|
|
45
116
|
},
|
|
46
117
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative2.Icon, {
|
|
47
118
|
name: preIcon,
|
|
48
|
-
size:
|
|
49
|
-
color: labelColor
|
|
119
|
+
size: _utils.isTablet ? tabletIconSize : iconSize,
|
|
120
|
+
color: currentButtonConfig.labelColor
|
|
50
121
|
})
|
|
51
|
-
}),
|
|
122
|
+
}), isMakingRequest ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
|
|
123
|
+
color: currentButtonConfig.labelColor
|
|
124
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Label, {
|
|
52
125
|
type: textVariant,
|
|
53
126
|
style: {
|
|
54
|
-
color: labelColor
|
|
127
|
+
color: currentButtonConfig.labelColor
|
|
55
128
|
},
|
|
56
129
|
children: label
|
|
57
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
|
|
58
|
-
color: labelColor
|
|
59
130
|
}), postIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
60
131
|
style: {
|
|
61
|
-
marginLeft: _constants.spacing[
|
|
132
|
+
marginLeft: _constants.spacing["size-2"]
|
|
62
133
|
},
|
|
63
134
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative2.Icon, {
|
|
64
135
|
name: postIcon,
|
|
65
|
-
size:
|
|
66
|
-
color: labelColor
|
|
136
|
+
size: _utils.isTablet ? tabletIconSize : iconSize,
|
|
137
|
+
color: currentButtonConfig.labelColor
|
|
67
138
|
})
|
|
68
139
|
})]
|
|
69
140
|
});
|
|
70
141
|
};
|
|
71
|
-
exports.DefaultButton = DefaultButton;
|
|
72
|
-
const styles = _reactNative.StyleSheet.create({});
|
|
142
|
+
exports.DefaultButton = DefaultButton;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
export type DialogModalTypes =
|
|
2
|
+
export type DialogModalTypes = "success" | "error" | "warning" | "info";
|
|
3
3
|
export type DialogModalConfig = {
|
|
4
4
|
variant: DialogModalTypes;
|
|
5
|
+
isWhiteBrand?: boolean;
|
|
5
6
|
title: string;
|
|
6
7
|
message: string;
|
|
7
8
|
buttonText?: string;
|
|
@@ -15,16 +15,55 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
15
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
const DialogModal = ({
|
|
17
17
|
variant,
|
|
18
|
+
isWhiteBrand = false,
|
|
18
19
|
title,
|
|
19
20
|
message,
|
|
20
|
-
buttonText =
|
|
21
|
+
buttonText = "Aceptar",
|
|
21
22
|
secondButtonText,
|
|
22
23
|
handlePrimaryBtn,
|
|
23
24
|
handleSecundaryBtn,
|
|
24
25
|
setShowAlert
|
|
25
26
|
}) => {
|
|
26
27
|
const animation = (0, _react.useRef)(null);
|
|
27
|
-
const
|
|
28
|
+
const getDialogConfig = () => {
|
|
29
|
+
switch (variant) {
|
|
30
|
+
case "success":
|
|
31
|
+
return {
|
|
32
|
+
lottieFile: require("../../assets/Lottie/afirmacion.json"),
|
|
33
|
+
iconName: "check-circle",
|
|
34
|
+
color: _constants.colors["Success-500"].light
|
|
35
|
+
};
|
|
36
|
+
case "error":
|
|
37
|
+
return {
|
|
38
|
+
lottieFile: require("../../assets/Lottie/buscando.json"),
|
|
39
|
+
iconName: "cross-circle",
|
|
40
|
+
color: _constants.colors["Error-500"].light
|
|
41
|
+
};
|
|
42
|
+
case "warning":
|
|
43
|
+
return {
|
|
44
|
+
lottieFile: require("../../assets/Lottie/alerta.json"),
|
|
45
|
+
iconName: "warning-circle",
|
|
46
|
+
color: _constants.colors["Warning-500"].light
|
|
47
|
+
};
|
|
48
|
+
case "info":
|
|
49
|
+
return {
|
|
50
|
+
lottieFile: require("../../assets/Lottie/pregunta.json"),
|
|
51
|
+
iconName: "info",
|
|
52
|
+
color: _constants.colors["Info-500"].light
|
|
53
|
+
};
|
|
54
|
+
default:
|
|
55
|
+
return {
|
|
56
|
+
lottieFile: require("../../assets/Lottie/pregunta.json"),
|
|
57
|
+
iconName: "info",
|
|
58
|
+
color: _constants.colors["Gray-400"].light
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const {
|
|
63
|
+
lottieFile,
|
|
64
|
+
iconName,
|
|
65
|
+
color
|
|
66
|
+
} = getDialogConfig();
|
|
28
67
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
29
68
|
style: styles.backgroundContainer,
|
|
30
69
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
@@ -39,7 +78,21 @@ const DialogModal = ({
|
|
|
39
78
|
color: _constants.colors["Gray-800"].light
|
|
40
79
|
})
|
|
41
80
|
})
|
|
42
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
81
|
+
}), isWhiteBrand ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
82
|
+
style: {
|
|
83
|
+
width: 84,
|
|
84
|
+
height: 84,
|
|
85
|
+
borderRadius: 42,
|
|
86
|
+
justifyContent: "center",
|
|
87
|
+
alignItems: "center",
|
|
88
|
+
backgroundColor: color
|
|
89
|
+
},
|
|
90
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative2.default, {
|
|
91
|
+
name: iconName,
|
|
92
|
+
size: 28,
|
|
93
|
+
color: _constants.colors["White"].light
|
|
94
|
+
})
|
|
95
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_lottieReactNative.default, {
|
|
43
96
|
autoPlay: true,
|
|
44
97
|
ref: animation,
|
|
45
98
|
style: styles.lottieAnimation,
|
|
@@ -60,7 +113,15 @@ const DialogModal = ({
|
|
|
60
113
|
})
|
|
61
114
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
62
115
|
style: styles.btnsContainer,
|
|
63
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_atoms.DefaultButton, {
|
|
116
|
+
children: [isWhiteBrand ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_atoms.DefaultButton, {
|
|
117
|
+
variant: variant,
|
|
118
|
+
size: "normal",
|
|
119
|
+
label: buttonText,
|
|
120
|
+
onPress: () => {
|
|
121
|
+
handlePrimaryBtn?.();
|
|
122
|
+
setShowAlert(false);
|
|
123
|
+
}
|
|
124
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_atoms.DefaultButton, {
|
|
64
125
|
variant: "primary",
|
|
65
126
|
size: "normal",
|
|
66
127
|
label: buttonText,
|
|
@@ -70,7 +131,20 @@ const DialogModal = ({
|
|
|
70
131
|
}
|
|
71
132
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
72
133
|
style: styles.buttonSpacer
|
|
73
|
-
}), secondButtonText && /*#__PURE__*/(0, _jsxRuntime.jsx)(_atoms.DefaultButton, {
|
|
134
|
+
}), secondButtonText && (isWhiteBrand ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_atoms.DefaultButton, {
|
|
135
|
+
variant: variant,
|
|
136
|
+
size: "normal",
|
|
137
|
+
label: secondButtonText,
|
|
138
|
+
onPress: () => {
|
|
139
|
+
handleSecundaryBtn?.();
|
|
140
|
+
setShowAlert(false);
|
|
141
|
+
},
|
|
142
|
+
buttonConfig: {
|
|
143
|
+
backgroundColor: "transparent",
|
|
144
|
+
labelColor: color,
|
|
145
|
+
borderColor: color
|
|
146
|
+
}
|
|
147
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_atoms.DefaultButton, {
|
|
74
148
|
variant: "secondary",
|
|
75
149
|
size: "normal",
|
|
76
150
|
label: secondButtonText,
|
|
@@ -78,7 +152,7 @@ const DialogModal = ({
|
|
|
78
152
|
handleSecundaryBtn?.();
|
|
79
153
|
setShowAlert(false);
|
|
80
154
|
}
|
|
81
|
-
})]
|
|
155
|
+
}))]
|
|
82
156
|
})]
|
|
83
157
|
})
|
|
84
158
|
});
|
|
@@ -95,41 +169,41 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
95
169
|
alignItems: "center"
|
|
96
170
|
},
|
|
97
171
|
dialogContainer: {
|
|
98
|
-
padding: _constants.spacing[
|
|
172
|
+
padding: _constants.spacing["size-5"],
|
|
99
173
|
backgroundColor: "white",
|
|
100
174
|
borderRadius: _constants.radius["border-3"],
|
|
101
175
|
width: "90%",
|
|
102
176
|
maxWidth: 600,
|
|
103
|
-
alignItems:
|
|
177
|
+
alignItems: "center"
|
|
104
178
|
},
|
|
105
179
|
titleContainer: {
|
|
106
|
-
marginTop: _constants.spacing[
|
|
180
|
+
marginTop: _constants.spacing["size-6"]
|
|
107
181
|
},
|
|
108
182
|
titleText: {
|
|
109
|
-
textAlign:
|
|
183
|
+
textAlign: "center"
|
|
110
184
|
},
|
|
111
185
|
messageContainer: {
|
|
112
|
-
marginTop: _constants.spacing[
|
|
186
|
+
marginTop: _constants.spacing["size-3"]
|
|
113
187
|
},
|
|
114
188
|
descriptionText: {
|
|
115
189
|
color: _constants.colors["Gray-400"].light,
|
|
116
|
-
textAlign:
|
|
190
|
+
textAlign: "center"
|
|
117
191
|
},
|
|
118
192
|
closeButtonContainer: {
|
|
119
|
-
width:
|
|
120
|
-
flexDirection:
|
|
121
|
-
justifyContent:
|
|
193
|
+
width: "100%",
|
|
194
|
+
flexDirection: "row",
|
|
195
|
+
justifyContent: "flex-end"
|
|
122
196
|
},
|
|
123
197
|
lottieAnimation: {
|
|
124
198
|
width: 100,
|
|
125
199
|
height: 100,
|
|
126
|
-
backgroundColor:
|
|
200
|
+
backgroundColor: "#fff"
|
|
127
201
|
},
|
|
128
202
|
btnsContainer: {
|
|
129
|
-
width:
|
|
130
|
-
marginTop: _constants.spacing[
|
|
203
|
+
width: "100%",
|
|
204
|
+
marginTop: _constants.spacing["size-6"]
|
|
131
205
|
},
|
|
132
206
|
buttonSpacer: {
|
|
133
|
-
height: _constants.spacing[
|
|
207
|
+
height: _constants.spacing["size-3"]
|
|
134
208
|
}
|
|
135
209
|
});
|
|
@@ -12,7 +12,7 @@ var _utils = require("../../../utils");
|
|
|
12
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
13
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
14
|
const ToastContext = exports.ToastContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
15
|
-
const DEFAULT_DURATION =
|
|
15
|
+
const DEFAULT_DURATION = 3000;
|
|
16
16
|
const ToastProvider = ({
|
|
17
17
|
children
|
|
18
18
|
}) => {
|
|
@@ -121,21 +121,6 @@ const ToastProvider = ({
|
|
|
121
121
|
animateInRef.current = animateIn;
|
|
122
122
|
}, [animateIn]);
|
|
123
123
|
|
|
124
|
-
// Auto-process queue when currentToast is null and queue has items
|
|
125
|
-
(0, _react.useEffect)(() => {
|
|
126
|
-
if (!currentToast && !isAnimating && queue.length > 0) {
|
|
127
|
-
// Defer to avoid state update during render
|
|
128
|
-
setTimeout(() => {
|
|
129
|
-
setQueue(prevQueue => {
|
|
130
|
-
if (prevQueue.length === 0) return prevQueue;
|
|
131
|
-
const [nextToast, ...remainingQueue] = prevQueue;
|
|
132
|
-
setCurrentToast(nextToast);
|
|
133
|
-
return remainingQueue;
|
|
134
|
-
});
|
|
135
|
-
}, 0);
|
|
136
|
-
}
|
|
137
|
-
}, [currentToast, isAnimating, queue.length]);
|
|
138
|
-
|
|
139
124
|
// Handle auto-dismiss - only depends on currentToast
|
|
140
125
|
(0, _react.useEffect)(() => {
|
|
141
126
|
if (!currentToast) return;
|