sapo-components-ui-rn 1.0.4 → 1.0.5
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/README.md +10 -6
- package/dist/assets/avatar.png +0 -0
- package/dist/assets/badge.png +0 -0
- package/dist/assets/button-icon.png +0 -0
- package/dist/assets/button.png +0 -0
- package/dist/assets/checkbox.png +0 -0
- package/dist/assets/chipbar.png +0 -0
- package/dist/assets/counting-dot.png +0 -0
- package/dist/assets/floating-button.png +0 -0
- package/dist/assets/image.png +0 -0
- package/dist/assets/images/avatar.png +0 -0
- package/dist/assets/images/badge.png +0 -0
- package/dist/assets/images/button-icon.png +0 -0
- package/dist/assets/images/button.png +0 -0
- package/dist/assets/images/checkbox.png +0 -0
- package/dist/assets/images/chipbar.png +0 -0
- package/dist/assets/images/counting-dot.png +0 -0
- package/dist/assets/images/floating-button.png +0 -0
- package/dist/assets/images/image.png +0 -0
- package/dist/assets/images/radio-button.png +0 -0
- package/dist/assets/images/search-input.png +0 -0
- package/dist/assets/images/selection-field.png +0 -0
- package/dist/assets/images/switch.png +0 -0
- package/dist/assets/images/text-area.png +0 -0
- package/dist/assets/images/text-input.png +0 -0
- package/dist/assets/images/toast.png +0 -0
- package/dist/assets/radio-button.png +0 -0
- package/dist/assets/search-input.png +0 -0
- package/dist/assets/selection-field.png +0 -0
- package/dist/assets/switch.png +0 -0
- package/dist/assets/text-area.png +0 -0
- package/dist/assets/text-input.png +0 -0
- package/dist/assets/toast.png +0 -0
- package/dist/components/Button/index.d.ts +6 -1
- package/dist/index.esm.js +45 -19
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +45 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/images/avatar.png +0 -0
- package/src/assets/images/badge.png +0 -0
- package/src/assets/images/button-icon.png +0 -0
- package/src/assets/images/button.png +0 -0
- package/src/assets/images/checkbox.png +0 -0
- package/src/assets/images/chipbar.png +0 -0
- package/src/assets/images/counting-dot.png +0 -0
- package/src/assets/images/floating-button.png +0 -0
- package/src/assets/images/image.png +0 -0
- package/src/assets/images/radio-button.png +0 -0
- package/src/assets/images/search-input.png +0 -0
- package/src/assets/images/selection-field.png +0 -0
- package/src/assets/images/switch.png +0 -0
- package/src/assets/images/text-area.png +0 -0
- package/src/assets/images/text-input.png +0 -0
- package/src/assets/images/toast.png +0 -0
- package/src/components/Button/index.tsx +23 -3
- package/src/components/FloatingButton/index.tsx +1 -0
- package/src/components/SelectionField/index.tsx +20 -15
- package/src/components/TextInput/TextInputDefault.tsx +8 -1
package/README.md
CHANGED
|
@@ -42,20 +42,24 @@ function MyComponent() {
|
|
|
42
42
|
|
|
43
43
|
Thư viện bao gồm các components sau:
|
|
44
44
|
|
|
45
|
-
- [Button](Button.md)
|
|
46
|
-
- [ButtonIcon](ButtonIcon.md)
|
|
47
|
-
- [Text](Text.md)
|
|
48
|
-
- [TextInput](TextInput.md)
|
|
49
45
|
- [Avatar](Avatar.md)
|
|
50
46
|
- [Badge](Badge.md)
|
|
47
|
+
- [Button](Button.md)
|
|
48
|
+
- [ButtonIcon](ButtonIcon.md)
|
|
51
49
|
- [Checkbox](Checkbox.md)
|
|
52
50
|
- [ChipBar](ChipBar.md)
|
|
53
|
-
- [RadioButton](RadioButton.md)
|
|
54
|
-
- [Switch](Switch.md)
|
|
55
51
|
- [CountingDot](CountingDot.md)
|
|
56
52
|
- [FloatingButton](FloatingButton.md)
|
|
57
53
|
- [Image](Image.md)
|
|
54
|
+
- [RadioButton](RadioButton.md)
|
|
55
|
+
- [SearchInput](SearchInput.md)
|
|
56
|
+
- [SelectionField](SelectionField.md)
|
|
58
57
|
- [Spacer](Spacer.md)
|
|
58
|
+
- [Switch](Switch.md)
|
|
59
|
+
- [Text](Text.md)
|
|
60
|
+
- [TextInput](TextInput.md)
|
|
61
|
+
- [TextArea](TextArea.md)
|
|
62
|
+
- [Toast](Toast.md)
|
|
59
63
|
- [View](View.md)
|
|
60
64
|
<!--
|
|
61
65
|
## Đóng góp
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { StyleProp, ViewStyle, TouchableOpacityProps, TextStyle } from "react-native";
|
|
3
|
+
import { IText } from "../Text";
|
|
3
4
|
import { ThemeProp } from "../../types";
|
|
4
5
|
export interface ButtonProps extends TouchableOpacityProps {
|
|
5
6
|
style?: StyleProp<ViewStyle>;
|
|
7
|
+
border?: boolean;
|
|
6
8
|
borderColor?: string;
|
|
7
9
|
title?: string;
|
|
8
10
|
backgroundColor?: string;
|
|
@@ -10,14 +12,17 @@ export interface ButtonProps extends TouchableOpacityProps {
|
|
|
10
12
|
left?: React.ReactNode;
|
|
11
13
|
right?: React.ReactNode;
|
|
12
14
|
small?: boolean;
|
|
15
|
+
margin?: Number;
|
|
16
|
+
textProps?: IText;
|
|
13
17
|
textColor?: string;
|
|
14
18
|
bold?: boolean;
|
|
15
19
|
size?: number;
|
|
16
20
|
textStyle?: TextStyle;
|
|
17
21
|
medium?: boolean;
|
|
18
22
|
mode?: "outlined" | "contained" | "transparent";
|
|
23
|
+
transparent?: boolean;
|
|
19
24
|
onPress?: (res?: any) => void;
|
|
20
25
|
theme?: ThemeProp;
|
|
21
26
|
}
|
|
22
|
-
declare const _default: React.MemoExoticComponent<({ style, title, borderColor, isLoading, left, right, small, textStyle, onPress, disabled, backgroundColor, textColor, bold, size, medium, mode, theme: themeOverrides, ...props }: ButtonProps) => React.JSX.Element>;
|
|
27
|
+
declare const _default: React.MemoExoticComponent<({ style, title, border, borderColor, isLoading, left, right, small, margin, textStyle, textProps, onPress, disabled, backgroundColor, textColor, bold, size, medium, mode, transparent, theme: themeOverrides, ...props }: ButtonProps) => React.JSX.Element>;
|
|
23
28
|
export default _default;
|
package/dist/index.esm.js
CHANGED
|
@@ -5524,13 +5524,14 @@ var Text = function (props) {
|
|
|
5524
5524
|
var Text$1 = memoDeepEqual(Text);
|
|
5525
5525
|
|
|
5526
5526
|
var TextInputDefault = function (_a) {
|
|
5527
|
-
var _b
|
|
5527
|
+
var _b;
|
|
5528
|
+
var _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.editable, editable = _d === void 0 ? true : _d, label = _a.label, _e = _a.error, error = _e === void 0 ? false : _e, customSelectionColor = _a.selectionColor, cursorColor = _a.cursorColor, customOutlineColor = _a.outlineColor, activeOutlineColor = _a.activeOutlineColor; _a.outlineStyle; var textColor = _a.textColor; _a.dense; var style = _a.style, theme = _a.theme, _f = _a.render, render = _f === void 0 ? function (props) { return React$3.createElement(TextInput$1, __assign({}, props)); } : _f, _g = _a.multiline, multiline = _g === void 0 ? false : _g, parentState = _a.parentState, innerRef = _a.innerRef, onFocus = _a.onFocus; _a.forceFocus; var onBlur = _a.onBlur, onChangeText = _a.onChangeText; _a.onLayout; var left = _a.left, right = _a.right, placeholderTextColor = _a.placeholderTextColor, _h = _a.clearButton, clearButton = _h === void 0 ? false : _h, contentStyle = _a.contentStyle, value = _a.value, rest = __rest(_a, ["disabled", "editable", "label", "error", "selectionColor", "cursorColor", "outlineColor", "activeOutlineColor", "outlineStyle", "textColor", "dense", "style", "theme", "render", "multiline", "parentState", "innerRef", "onFocus", "forceFocus", "onBlur", "onChangeText", "onLayout", "left", "right", "placeholderTextColor", "clearButton", "contentStyle", "value"]);
|
|
5528
5529
|
var colors = theme.colors;
|
|
5529
5530
|
var font = theme.fonts.bodyLarge;
|
|
5530
|
-
var
|
|
5531
|
+
var _j = (StyleSheet.flatten(style) || {}), fontSizeStyle = _j.fontSize, fontWeight = _j.fontWeight, lineHeightStyle = _j.lineHeight, height = _j.height, _k = _j.backgroundColor; _k === void 0 ? colors === null || colors === void 0 ? void 0 : colors.backgroundPrimary : _k; var textAlign = _j.textAlign, viewStyle = __rest(_j, ["fontSize", "fontWeight", "lineHeight", "height", "backgroundColor", "textAlign"]);
|
|
5531
5532
|
var fontSize = fontSizeStyle || MAXIMIZED_LABEL_FONT_SIZE;
|
|
5532
5533
|
var lineHeight = lineHeightStyle || (Platform.OS === "web" ? fontSize * 1.2 : undefined);
|
|
5533
|
-
var
|
|
5534
|
+
var _l = getOutlinedInputColors({
|
|
5534
5535
|
activeOutlineColor: activeOutlineColor,
|
|
5535
5536
|
customOutlineColor: customOutlineColor,
|
|
5536
5537
|
customSelectionColor: customSelectionColor,
|
|
@@ -5538,8 +5539,8 @@ var TextInputDefault = function (_a) {
|
|
|
5538
5539
|
disabled: disabled,
|
|
5539
5540
|
error: error,
|
|
5540
5541
|
theme: theme,
|
|
5541
|
-
}), inputTextColor =
|
|
5542
|
-
var
|
|
5542
|
+
}), inputTextColor = _l.inputTextColor, activeColor = _l.activeColor, selectionColor = _l.selectionColor;
|
|
5543
|
+
var _m = React$3.useState(value || ""), inputValue = _m[0], setInputValue = _m[1];
|
|
5543
5544
|
React$3.useEffect(function () {
|
|
5544
5545
|
setInputValue(value || "");
|
|
5545
5546
|
}, [value]);
|
|
@@ -5601,7 +5602,11 @@ var TextInputDefault = function (_a) {
|
|
|
5601
5602
|
left && React$3.createElement(Spacer, { width: CONSTANTS.SPACE_8 }),
|
|
5602
5603
|
React$3.createElement(View, { full: true },
|
|
5603
5604
|
multiline && renderLabel(), render === null || render === void 0 ? void 0 :
|
|
5604
|
-
render(__assign(__assign({}, rest), { ref: innerRef, onChangeText: handleChangeText, value: inputValue, placeholder:
|
|
5605
|
+
render(__assign(__assign({}, rest), { ref: innerRef, onChangeText: handleChangeText, value: inputValue, placeholder: ((_b = parentState.value) === null || _b === void 0 ? void 0 : _b.toString()) == ""
|
|
5606
|
+
? parentState.focused
|
|
5607
|
+
? rest.placeholder
|
|
5608
|
+
: label
|
|
5609
|
+
: rest.placeholder, editable: !disabled && editable, selectionColor: selectionColor, cursorColor: typeof cursorColor === "undefined" ? activeColor : cursorColor, placeholderTextColor: placeholderTextColorBasedOnState, onFocus: onFocus, onBlur: onBlur, underlineColorAndroid: "transparent", multiline: multiline, style: [
|
|
5605
5610
|
styles$a.input,
|
|
5606
5611
|
__assign(__assign({}, font), { fontSize: fontSize, lineHeight: lineHeight, fontWeight: fontWeight, color: inputTextColor, textAlignVertical: multiline ? "top" : "center", textAlign: textAlign
|
|
5607
5612
|
? textAlign
|
|
@@ -5623,6 +5628,8 @@ var styles$a = StyleSheet.create({
|
|
|
5623
5628
|
},
|
|
5624
5629
|
clearButton: {
|
|
5625
5630
|
padding: CONSTANTS.SPACE_8,
|
|
5631
|
+
height: "100%",
|
|
5632
|
+
paddingTop: CONSTANTS.SPACE_16,
|
|
5626
5633
|
},
|
|
5627
5634
|
});
|
|
5628
5635
|
|
|
@@ -5887,7 +5894,7 @@ var ScaleButton = function (_a) {
|
|
|
5887
5894
|
var ScaleButton$1 = React__default.memo(ScaleButton);
|
|
5888
5895
|
|
|
5889
5896
|
var Button = function (_a) {
|
|
5890
|
-
var style = _a.style, title = _a.title
|
|
5897
|
+
var style = _a.style, title = _a.title; _a.border; var borderColor = _a.borderColor, isLoading = _a.isLoading, left = _a.left, right = _a.right, small = _a.small; _a.margin; var textStyle = _a.textStyle, textProps = _a.textProps, onPress = _a.onPress, disabled = _a.disabled, backgroundColor = _a.backgroundColor, textColor = _a.textColor, _b = _a.bold, bold = _b === void 0 ? true : _b, _c = _a.size, size = _c === void 0 ? 16 : _c, _d = _a.medium, medium = _d === void 0 ? false : _d, _e = _a.mode, mode = _e === void 0 ? "contained" : _e; _a.transparent; _a.theme; var props = __rest(_a, ["style", "title", "border", "borderColor", "isLoading", "left", "right", "small", "margin", "textStyle", "textProps", "onPress", "disabled", "backgroundColor", "textColor", "bold", "size", "medium", "mode", "transparent", "theme"]);
|
|
5891
5898
|
var theme = useInternalTheme();
|
|
5892
5899
|
var colors = theme.colors;
|
|
5893
5900
|
var disabledTextStyle = {
|
|
@@ -5906,6 +5913,16 @@ var Button = function (_a) {
|
|
|
5906
5913
|
];
|
|
5907
5914
|
}
|
|
5908
5915
|
};
|
|
5916
|
+
var renderTextColor = function () {
|
|
5917
|
+
switch (mode) {
|
|
5918
|
+
case "outlined":
|
|
5919
|
+
return colors.textBrandDefault;
|
|
5920
|
+
case "contained":
|
|
5921
|
+
return colors.textOnFillDefault;
|
|
5922
|
+
case "transparent":
|
|
5923
|
+
return colors.textBrandDefault;
|
|
5924
|
+
}
|
|
5925
|
+
};
|
|
5909
5926
|
return (React__default.createElement(View, { style: styles$9.container },
|
|
5910
5927
|
React__default.createElement(ScaleButton$1, __assign({ activeOpacity: 0.8, onPress: onPress }, props, { disabled: disabled || false }),
|
|
5911
5928
|
React__default.createElement(View, { style: [
|
|
@@ -5933,7 +5950,7 @@ var Button = function (_a) {
|
|
|
5933
5950
|
React__default.createElement(Spacer, { width: left ? CONSTANTS.SPACE_12 : CONSTANTS.SPACE_16 }),
|
|
5934
5951
|
!isLoading && left,
|
|
5935
5952
|
left && React__default.createElement(Spacer, { width: CONSTANTS.SPACE_8 }),
|
|
5936
|
-
isLoading ? (React__default.createElement(ActivityIndicator$1, { color: (textStyle === null || textStyle === void 0 ? void 0 : textStyle.color) || colors.borderBrandDefault })) : (React__default.createElement(Text$1, { numberOfLines: 1, color: textColor ||
|
|
5953
|
+
isLoading ? (React__default.createElement(ActivityIndicator$1, { color: (textStyle === null || textStyle === void 0 ? void 0 : textStyle.color) || colors.borderBrandDefault })) : (React__default.createElement(Text$1, __assign({ numberOfLines: 1, color: textColor || renderTextColor(), size: size, bold: bold, medium: medium, style: [disabled && disabledTextStyle, textStyle] }, textProps), title)),
|
|
5937
5954
|
right && React__default.createElement(Spacer, { width: CONSTANTS.SPACE_8 }),
|
|
5938
5955
|
!isLoading && right,
|
|
5939
5956
|
React__default.createElement(Spacer, { width: right ? CONSTANTS.SPACE_12 : CONSTANTS.SPACE_16 })))));
|
|
@@ -6040,6 +6057,7 @@ var styles$7 = StyleSheet.create({
|
|
|
6040
6057
|
shadowOpacity: 0.25,
|
|
6041
6058
|
shadowRadius: 3.84,
|
|
6042
6059
|
elevation: 5,
|
|
6060
|
+
zIndex: 99,
|
|
6043
6061
|
},
|
|
6044
6062
|
});
|
|
6045
6063
|
var index$1 = memoDeepEqual(FloatingButton);
|
|
@@ -6369,10 +6387,18 @@ var Badge = function (_a) {
|
|
|
6369
6387
|
|
|
6370
6388
|
Dimensions.get("window").height;
|
|
6371
6389
|
Dimensions.get("window").width;
|
|
6390
|
+
var BUTTON_HEIGHT = 48;
|
|
6391
|
+
var BUTTON_HEIGHT_SMALL = 40;
|
|
6392
|
+
var SPACE_4 = 4;
|
|
6393
|
+
var SPACE_6 = 6;
|
|
6372
6394
|
var SPACE_8 = 8;
|
|
6395
|
+
var SPACE_12 = 12;
|
|
6373
6396
|
var SPACE_16 = 16;
|
|
6397
|
+
//MARK: Border radius
|
|
6398
|
+
var BORDER_RADIUS_6 = 6;
|
|
6374
6399
|
//MARK: Border width
|
|
6375
6400
|
StyleSheet.hairlineWidth; //0.3-0.5
|
|
6401
|
+
var BORDER_WIDTH_1 = 1;
|
|
6376
6402
|
|
|
6377
6403
|
var containerStyles = StyleSheet.create({
|
|
6378
6404
|
container: { flex: 1 },
|
|
@@ -6682,9 +6708,9 @@ var SelectionField = function (_a) {
|
|
|
6682
6708
|
React__default.createElement(View, { style: [
|
|
6683
6709
|
styles.container,
|
|
6684
6710
|
{
|
|
6685
|
-
borderRadius:
|
|
6711
|
+
borderRadius: BORDER_RADIUS_6,
|
|
6686
6712
|
},
|
|
6687
|
-
[styles.border, { borderColor: colors.
|
|
6713
|
+
[styles.border, { borderColor: colors.borderPrimaryDefault }],
|
|
6688
6714
|
borderColor && { borderColor: borderColor },
|
|
6689
6715
|
disabled && [
|
|
6690
6716
|
styles.disabled,
|
|
@@ -6701,9 +6727,9 @@ var SelectionField = function (_a) {
|
|
|
6701
6727
|
],
|
|
6702
6728
|
style,
|
|
6703
6729
|
] },
|
|
6704
|
-
React__default.createElement(Spacer, { width:
|
|
6730
|
+
React__default.createElement(Spacer, { width: SPACE_12 }),
|
|
6705
6731
|
React__default.createElement(View, { full: true },
|
|
6706
|
-
label.toString() !== "" && (React__default.createElement(Text$1, { color: labelColor || colors.textSecondary, style: [
|
|
6732
|
+
content.toString() !== "" && label.toString() !== "" && (React__default.createElement(Text$1, { color: labelColor || colors.textSecondary, style: [
|
|
6707
6733
|
styles.text12,
|
|
6708
6734
|
disabled && {
|
|
6709
6735
|
color: colors.textPlaceholder,
|
|
@@ -6712,22 +6738,22 @@ var SelectionField = function (_a) {
|
|
|
6712
6738
|
color: colors.textErrorDefault,
|
|
6713
6739
|
},
|
|
6714
6740
|
] }, label)),
|
|
6715
|
-
React__default.createElement(Text$1, __assign({ numberOfLines: 1, color: textColor || colors.textDefault, size: size, style: [disabled && disabledTextStyle, textStyle] }, textProps), content)),
|
|
6741
|
+
React__default.createElement(Text$1, __assign({ numberOfLines: 1, color: textColor || colors.textDefault, size: size, style: [disabled && disabledTextStyle, textStyle] }, textProps), content.toString() === "" ? label : content)),
|
|
6716
6742
|
right || React__default.createElement(Icon$1, { name: "IconArrowDown", type: "Svg", size: 24 }),
|
|
6717
|
-
React__default.createElement(Spacer, { width:
|
|
6718
|
-
error.length > 0 && (React__default.createElement(View, { paddingHorizontal:
|
|
6743
|
+
React__default.createElement(Spacer, { width: SPACE_12 }))),
|
|
6744
|
+
error.length > 0 && (React__default.createElement(View, { paddingHorizontal: SPACE_12, paddingVertical: SPACE_4 },
|
|
6719
6745
|
React__default.createElement(Text$1, { style: styles.text12, color: colors.textErrorDefault }, error)))));
|
|
6720
6746
|
};
|
|
6721
6747
|
var styles = StyleSheet.create(__assign(__assign({}, containerStyles), { disabled: { opacity: 0.6 }, container: {
|
|
6722
|
-
minHeight:
|
|
6748
|
+
minHeight: BUTTON_HEIGHT,
|
|
6723
6749
|
flexDirection: "row",
|
|
6724
6750
|
alignItems: "center",
|
|
6725
6751
|
justifyContent: "space-between",
|
|
6726
|
-
paddingVertical:
|
|
6752
|
+
paddingVertical: SPACE_6,
|
|
6727
6753
|
}, border: {
|
|
6728
|
-
borderWidth:
|
|
6754
|
+
borderWidth: BORDER_WIDTH_1,
|
|
6729
6755
|
}, small: {
|
|
6730
|
-
height:
|
|
6756
|
+
height: BUTTON_HEIGHT_SMALL,
|
|
6731
6757
|
} }));
|
|
6732
6758
|
var index = React__default.memo(SelectionField);
|
|
6733
6759
|
|