sapo-components-ui-rn 1.1.71 → 1.1.73
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/dist/components/SearchInput/index.d.ts +3 -2
- package/dist/components/Switch/Switch.d.ts +2 -1
- package/dist/index.esm.js +65 -103
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +65 -103
- package/dist/index.js.map +1 -1
- package/dist/styles/themes/tokens.d.ts +4 -0
- package/dist/theme/container-styles.d.ts +0 -57
- package/dist/theme/themes.d.ts +2 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/SearchInput/index.tsx +12 -2
- package/src/components/Switch/Switch.tsx +113 -92
- package/src/components/TextInput/TextInputDefault.tsx +5 -13
- package/src/styles/themes/tokens.tsx +2 -0
- package/src/theme/container-styles.tsx +0 -55
- package/src/types.ts +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { StyleProp, ViewStyle, TextStyle } from "react-native";
|
|
2
|
+
import { StyleProp, ViewStyle, TextStyle, TextInput as TextInputNative } from "react-native";
|
|
3
3
|
interface SearchInputProps {
|
|
4
4
|
style?: StyleProp<ViewStyle>;
|
|
5
5
|
value?: string;
|
|
@@ -15,6 +15,7 @@ interface SearchInputProps {
|
|
|
15
15
|
height?: number;
|
|
16
16
|
debounceTime?: number;
|
|
17
17
|
autoFocus?: boolean;
|
|
18
|
+
ref?: React.RefObject<TextInputNative | null>;
|
|
18
19
|
}
|
|
19
|
-
declare const SearchInput: ({ value, disabled, rightIcon, clearButton, placeholder, onFocus, onBlur, onChangeText, style, height, debounceTime, autoFocus, textStyle, }: SearchInputProps) => React.JSX.Element;
|
|
20
|
+
declare const SearchInput: ({ value, disabled, rightIcon, clearButton, placeholder, onFocus, onBlur, onChangeText, style, height, debounceTime, autoFocus, textStyle, ref, }: SearchInputProps) => React.JSX.Element;
|
|
20
21
|
export default SearchInput;
|
|
@@ -8,10 +8,11 @@ export type Props = {
|
|
|
8
8
|
* Value of the switch, true means 'on', false means 'off'.
|
|
9
9
|
*/
|
|
10
10
|
value?: boolean;
|
|
11
|
+
size?: "small" | "normal";
|
|
11
12
|
/**
|
|
12
13
|
* Callback called with the new value when it changes.
|
|
13
14
|
*/
|
|
14
15
|
onValueChange?: (value: boolean) => void;
|
|
15
16
|
};
|
|
16
|
-
declare const Switch: React.MemoExoticComponent<({ value, disabled, onValueChange }: Props) => React.JSX.Element>;
|
|
17
|
+
declare const Switch: React.MemoExoticComponent<({ value, disabled, onValueChange, size }: Props) => React.JSX.Element>;
|
|
17
18
|
export default Switch;
|
package/dist/index.esm.js
CHANGED
|
@@ -249,6 +249,7 @@ var ref = {
|
|
|
249
249
|
borderCriticalPressed: red.RED120,
|
|
250
250
|
borderErrorDefault: red.RED100,
|
|
251
251
|
borderInfoDefault: blue.BLUE100,
|
|
252
|
+
borderInfoInverseDefault: blue.BLUE40,
|
|
252
253
|
borderPrimaryDefault: ink.INK10,
|
|
253
254
|
borderPrimaryDisabled: ink.INK20,
|
|
254
255
|
borderPrimaryHovered: ink.INK40,
|
|
@@ -410,6 +411,7 @@ var ref = {
|
|
|
410
411
|
borderCriticalPressed: red.RED120,
|
|
411
412
|
borderErrorDefault: red.RED100,
|
|
412
413
|
borderInfoDefault: blue.BLUE100,
|
|
414
|
+
borderInfoInverseDefault: blue.BLUE40,
|
|
413
415
|
borderPrimaryDefault: ink.INK10,
|
|
414
416
|
borderPrimaryDisabled: ink.INK20,
|
|
415
417
|
borderPrimaryHovered: ink.INK40,
|
|
@@ -652,72 +654,7 @@ var CONSTANTS = {
|
|
|
652
654
|
FONT_WEIGHT_BLACK: "900",
|
|
653
655
|
};
|
|
654
656
|
|
|
655
|
-
Dimensions.get("window").height;
|
|
656
|
-
Dimensions.get("window").width;
|
|
657
|
-
var BUTTON_HEIGHT = 48;
|
|
658
|
-
var BUTTON_HEIGHT_SMALL = 40;
|
|
659
|
-
var SPACE_4 = 4;
|
|
660
|
-
var SPACE_6 = 6;
|
|
661
|
-
var SPACE_8 = 8;
|
|
662
|
-
var SPACE_12 = 12;
|
|
663
|
-
var SPACE_16 = 16;
|
|
664
|
-
var SPACE_40 = 40;
|
|
665
|
-
//MARK: Border radius
|
|
666
|
-
var BORDER_RADIUS_6 = 6;
|
|
667
|
-
//MARK: Border width
|
|
668
|
-
StyleSheet.hairlineWidth; //0.3-0.5
|
|
669
|
-
var BORDER_WIDTH_1 = 1;
|
|
670
|
-
|
|
671
657
|
var containerStyles = StyleSheet.create({
|
|
672
|
-
container: { flex: 1 },
|
|
673
|
-
center: {
|
|
674
|
-
paddingHorizontal: SPACE_16,
|
|
675
|
-
alignItems: "center",
|
|
676
|
-
justifyContent: "center",
|
|
677
|
-
},
|
|
678
|
-
end: { alignItems: "flex-end" },
|
|
679
|
-
start: { alignItems: "flex-start" },
|
|
680
|
-
centerHorizontal: { justifyContent: "center" },
|
|
681
|
-
icon: {
|
|
682
|
-
backgroundColor: blue.BLUE100,
|
|
683
|
-
justifyContent: "center",
|
|
684
|
-
alignItems: "center",
|
|
685
|
-
},
|
|
686
|
-
row: {
|
|
687
|
-
flexDirection: "row",
|
|
688
|
-
},
|
|
689
|
-
txtSmallBold: {
|
|
690
|
-
fontSize: 12,
|
|
691
|
-
color: ink.INK80,
|
|
692
|
-
fontWeight: "600",
|
|
693
|
-
},
|
|
694
|
-
button: {
|
|
695
|
-
borderRadius: 20,
|
|
696
|
-
justifyContent: "center",
|
|
697
|
-
alignItems: "center",
|
|
698
|
-
width: 40,
|
|
699
|
-
height: 40,
|
|
700
|
-
backgroundColor: white.WHITE100,
|
|
701
|
-
marginHorizontal: SPACE_8,
|
|
702
|
-
},
|
|
703
|
-
shadow: {
|
|
704
|
-
shadowColor: "black",
|
|
705
|
-
shadowOffset: {
|
|
706
|
-
width: 1,
|
|
707
|
-
height: 2,
|
|
708
|
-
},
|
|
709
|
-
shadowOpacity: 0.3,
|
|
710
|
-
shadowRadius: 5,
|
|
711
|
-
},
|
|
712
|
-
hitSlop: {
|
|
713
|
-
top: 10,
|
|
714
|
-
right: 10,
|
|
715
|
-
bottom: 10,
|
|
716
|
-
left: 10,
|
|
717
|
-
},
|
|
718
|
-
transparent: {
|
|
719
|
-
backgroundColor: "transparent",
|
|
720
|
-
},
|
|
721
658
|
//MARK: text size
|
|
722
659
|
text10: {
|
|
723
660
|
fontSize: 11,
|
|
@@ -1594,7 +1531,7 @@ var ViewCustom = forwardRef$1(function (_a, ref) {
|
|
|
1594
1531
|
var View = React__default.memo(ViewCustom);
|
|
1595
1532
|
|
|
1596
1533
|
var Switch = memo(function (_a) {
|
|
1597
|
-
var value = _a.value, disabled = _a.disabled, onValueChange = _a.onValueChange;
|
|
1534
|
+
var value = _a.value, disabled = _a.disabled, onValueChange = _a.onValueChange, _b = _a.size, size = _b === void 0 ? "normal" : _b;
|
|
1598
1535
|
var theme = useInternalTheme();
|
|
1599
1536
|
var colors = theme.colors;
|
|
1600
1537
|
var progress = useSharedValue(value ? 1 : 0);
|
|
@@ -1634,26 +1571,42 @@ var Switch = memo(function (_a) {
|
|
|
1634
1571
|
}));
|
|
1635
1572
|
}
|
|
1636
1573
|
}, [value]);
|
|
1574
|
+
var getSizeSwitch = useCallback(function () {
|
|
1575
|
+
switch (size) {
|
|
1576
|
+
case "small":
|
|
1577
|
+
return {
|
|
1578
|
+
width: 48,
|
|
1579
|
+
height: 28,
|
|
1580
|
+
};
|
|
1581
|
+
default:
|
|
1582
|
+
return {
|
|
1583
|
+
width: 52,
|
|
1584
|
+
height: 32,
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1587
|
+
}, [size]);
|
|
1588
|
+
var getSizeCircle = useCallback(function () {
|
|
1589
|
+
switch (size) {
|
|
1590
|
+
case "small":
|
|
1591
|
+
return {
|
|
1592
|
+
width: 24,
|
|
1593
|
+
height: 24,
|
|
1594
|
+
borderRadius: 12,
|
|
1595
|
+
backgroundColor: colors.surfacePrimaryDefault,
|
|
1596
|
+
};
|
|
1597
|
+
default:
|
|
1598
|
+
return {
|
|
1599
|
+
width: 28,
|
|
1600
|
+
height: 28,
|
|
1601
|
+
borderRadius: 14,
|
|
1602
|
+
backgroundColor: colors.surfacePrimaryDefault,
|
|
1603
|
+
};
|
|
1604
|
+
}
|
|
1605
|
+
}, [size, colors]);
|
|
1637
1606
|
return (React$3.createElement(View, { row: true },
|
|
1638
1607
|
React$3.createElement(TouchableOpacity, { activeOpacity: 1, onPress: handleSwitch, disabled: disabled, style: disabled ? { opacity: 0.6 } : {} },
|
|
1639
|
-
React$3.createElement(Animated.View, { style: [
|
|
1640
|
-
|
|
1641
|
-
backgroundColor,
|
|
1642
|
-
{
|
|
1643
|
-
width: 52,
|
|
1644
|
-
height: 32,
|
|
1645
|
-
},
|
|
1646
|
-
] },
|
|
1647
|
-
React$3.createElement(Animated.View, { style: [
|
|
1648
|
-
styles$j.animated,
|
|
1649
|
-
animatedStyle,
|
|
1650
|
-
{
|
|
1651
|
-
width: 28,
|
|
1652
|
-
height: 28,
|
|
1653
|
-
borderRadius: 14,
|
|
1654
|
-
backgroundColor: colors.surfacePrimaryDefault,
|
|
1655
|
-
},
|
|
1656
|
-
] })))));
|
|
1608
|
+
React$3.createElement(Animated.View, { style: [styles$j.vSegment, backgroundColor, getSizeSwitch()] },
|
|
1609
|
+
React$3.createElement(Animated.View, { style: [styles$j.animated, animatedStyle, getSizeCircle()] })))));
|
|
1657
1610
|
});
|
|
1658
1611
|
var styles$j = StyleSheet.create({
|
|
1659
1612
|
vSegment: {
|
|
@@ -4779,6 +4732,22 @@ var Spacer = function (_a) {
|
|
|
4779
4732
|
return (React__default.createElement(View, { backgroundColor: backgroundColor || "transparent", width: width, height: height, style: [style] }));
|
|
4780
4733
|
};
|
|
4781
4734
|
|
|
4735
|
+
Dimensions.get("window").height;
|
|
4736
|
+
Dimensions.get("window").width;
|
|
4737
|
+
var BUTTON_HEIGHT = 48;
|
|
4738
|
+
var BUTTON_HEIGHT_SMALL = 40;
|
|
4739
|
+
var SPACE_4 = 4;
|
|
4740
|
+
var SPACE_6 = 6;
|
|
4741
|
+
var SPACE_8 = 8;
|
|
4742
|
+
var SPACE_12 = 12;
|
|
4743
|
+
var SPACE_16 = 16;
|
|
4744
|
+
var SPACE_40 = 40;
|
|
4745
|
+
//MARK: Border radius
|
|
4746
|
+
var BORDER_RADIUS_6 = 6;
|
|
4747
|
+
//MARK: Border width
|
|
4748
|
+
StyleSheet.hairlineWidth; //0.3-0.5
|
|
4749
|
+
var BORDER_WIDTH_1 = 1;
|
|
4750
|
+
|
|
4782
4751
|
var ICON100 = "#46515F";
|
|
4783
4752
|
var ICON50 = "#A1A5AB";
|
|
4784
4753
|
var icon = {
|
|
@@ -5161,14 +5130,14 @@ var styles$e = StyleSheet.create({
|
|
|
5161
5130
|
});
|
|
5162
5131
|
|
|
5163
5132
|
var TextInputDefault = function (_a) {
|
|
5164
|
-
var _b
|
|
5165
|
-
var
|
|
5133
|
+
var _b;
|
|
5134
|
+
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, prefix = _a.prefix, suffix = _a.suffix, placeholderTextColor = _a.placeholderTextColor, _h = _a.clearButton, clearButton = _h === void 0 ? false : _h, contentStyle = _a.contentStyle, _j = _a.value, value = _j === void 0 ? "" : _j, textError = _a.textError, required = _a.required, 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", "prefix", "suffix", "placeholderTextColor", "clearButton", "contentStyle", "value", "textError", "required"]);
|
|
5166
5135
|
var colors = theme.colors;
|
|
5167
5136
|
var font = theme.fonts.bodyLarge;
|
|
5168
|
-
var
|
|
5137
|
+
var _k = (StyleSheet.flatten(style) || {}), fontSizeStyle = _k.fontSize, fontWeight = _k.fontWeight, lineHeightStyle = _k.lineHeight, height = _k.height, _l = _k.backgroundColor; _l === void 0 ? colors === null || colors === void 0 ? void 0 : colors.backgroundPrimary : _l; var textAlign = _k.textAlign; _k.minHeight; var viewStyle = __rest(_k, ["fontSize", "fontWeight", "lineHeight", "height", "backgroundColor", "textAlign", "minHeight"]);
|
|
5169
5138
|
var fontSize = fontSizeStyle || MAXIMIZED_LABEL_FONT_SIZE;
|
|
5170
5139
|
var lineHeight = lineHeightStyle || (Platform.OS === "web" ? fontSize * 1.2 : undefined);
|
|
5171
|
-
var
|
|
5140
|
+
var _m = getOutlinedInputColors({
|
|
5172
5141
|
activeOutlineColor: activeOutlineColor,
|
|
5173
5142
|
customOutlineColor: customOutlineColor,
|
|
5174
5143
|
customSelectionColor: customSelectionColor,
|
|
@@ -5176,8 +5145,8 @@ var TextInputDefault = function (_a) {
|
|
|
5176
5145
|
disabled: disabled,
|
|
5177
5146
|
error: error,
|
|
5178
5147
|
theme: theme,
|
|
5179
|
-
}), inputTextColor =
|
|
5180
|
-
var
|
|
5148
|
+
}), inputTextColor = _m.inputTextColor, activeColor = _m.activeColor, selectionColor = _m.selectionColor;
|
|
5149
|
+
var _o = React$3.useState(value || ""), inputValue = _o[0], setInputValue = _o[1];
|
|
5181
5150
|
React$3.useEffect(function () {
|
|
5182
5151
|
if (value === undefined) {
|
|
5183
5152
|
setInputValue("");
|
|
@@ -5344,22 +5313,15 @@ var TextInputDefault = function (_a) {
|
|
|
5344
5313
|
] }))) : (React$3.createElement(View, { style: {
|
|
5345
5314
|
flexDirection: "row",
|
|
5346
5315
|
} },
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
(prefix === null || prefix === void 0 ? void 0 : prefix.toString()) !== "" &&
|
|
5350
|
-
renderPrefix(), render === null || render === void 0 ? void 0 :
|
|
5351
|
-
render(__assign(__assign({}, rest), { ref: innerRef, onChangeText: handleChangeText, value: inputValue, placeholder: ((_c = parentState.value) === null || _c === void 0 ? void 0 : _c.toString()) == ""
|
|
5352
|
-
? parentState.focused
|
|
5353
|
-
? rest.placeholder
|
|
5354
|
-
: label
|
|
5355
|
-
: rest.placeholder, editable: !disabled && editable, selectionColor: selectionColor, cursorColor: typeof cursorColor === "undefined"
|
|
5316
|
+
prefix && (prefix === null || prefix === void 0 ? void 0 : prefix.toString()) !== "" && renderPrefix(), render === null || render === void 0 ? void 0 :
|
|
5317
|
+
render(__assign(__assign({}, rest), { ref: innerRef, onChangeText: handleChangeText, value: inputValue, placeholder: rest.placeholder, editable: !disabled && editable, selectionColor: selectionColor, cursorColor: typeof cursorColor === "undefined"
|
|
5356
5318
|
? activeColor
|
|
5357
5319
|
: cursorColor, placeholderTextColor: placeholderTextColorBasedOnState, onFocus: onFocus, onBlur: onBlur, underlineColorAndroid: "transparent", multiline: multiline, style: [
|
|
5358
5320
|
styles$d.input,
|
|
5359
|
-
__assign(__assign({}, font), { fontSize: fontSize, lineHeight: lineHeight, fontWeight: fontWeight, color: inputTextColor, textAlignVertical:
|
|
5321
|
+
__assign(__assign({}, font), { fontSize: fontSize, lineHeight: lineHeight, fontWeight: fontWeight, color: inputTextColor, textAlignVertical: "center", height: height ? height : 48, paddingTop: getPaddingTopValue(), paddingBottom: 0 }),
|
|
5360
5322
|
contentStyle,
|
|
5361
5323
|
] })),
|
|
5362
|
-
|
|
5324
|
+
renderSuffix()))),
|
|
5363
5325
|
!disabled && clearButton && inputValue ? (React$3.createElement(TouchableOpacity, { onPress: handleClear, style: multiline ? styles$d.clearButtonMultiline : styles$d.clearButton },
|
|
5364
5326
|
React$3.createElement(SvgIcon, { name: "IconClearText", width: 24, height: 24 }))) : (React$3.createElement(Spacer, { width: CONSTANTS.SPACE_12 })),
|
|
5365
5327
|
checkLineRightAction() && (React$3.createElement(Spacer, { width: 1, height: 24, backgroundColor: colors.borderPrimaryDefault, style: {
|
|
@@ -7236,14 +7198,14 @@ var styles$2 = StyleSheet.create(__assign(__assign({}, containerStyles), { disab
|
|
|
7236
7198
|
var index$1 = React__default.memo(SelectionField);
|
|
7237
7199
|
|
|
7238
7200
|
var SearchInput = function (_a) {
|
|
7239
|
-
var _b = _a.value, value = _b === void 0 ? "" : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, rightIcon = _a.rightIcon, _d = _a.clearButton, clearButton = _d === void 0 ? false : _d, _e = _a.placeholder, placeholder = _e === void 0 ? "Tìm kiếm" : _e, onFocus = _a.onFocus, onBlur = _a.onBlur, onChangeText = _a.onChangeText, style = _a.style, height = _a.height, _f = _a.debounceTime, debounceTime = _f === void 0 ? 500 : _f, _g = _a.autoFocus, autoFocus = _g === void 0 ? false : _g, textStyle = _a.textStyle;
|
|
7201
|
+
var _b = _a.value, value = _b === void 0 ? "" : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, rightIcon = _a.rightIcon, _d = _a.clearButton, clearButton = _d === void 0 ? false : _d, _e = _a.placeholder, placeholder = _e === void 0 ? "Tìm kiếm" : _e, onFocus = _a.onFocus, onBlur = _a.onBlur, onChangeText = _a.onChangeText, style = _a.style, height = _a.height, _f = _a.debounceTime, debounceTime = _f === void 0 ? 500 : _f, _g = _a.autoFocus, autoFocus = _g === void 0 ? false : _g, textStyle = _a.textStyle, ref = _a.ref;
|
|
7240
7202
|
var theme = useInternalTheme();
|
|
7241
7203
|
var colors = theme.colors;
|
|
7242
7204
|
var debouncedOnChangeText = useDebouncedCallback(function (text) {
|
|
7243
7205
|
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(text);
|
|
7244
7206
|
}, debounceTime);
|
|
7245
7207
|
return (React__default.createElement(TextInput, { left: React__default.createElement(View, null,
|
|
7246
|
-
React__default.createElement(SvgIcon, { name: "IconSearch", width: 24, height: 24 })), disabled: disabled, value: value, clearButton: clearButton, mode: "default",
|
|
7208
|
+
React__default.createElement(SvgIcon, { name: "IconSearch", width: 24, height: 24 })), ref: ref, disabled: disabled, value: value, clearButton: clearButton, mode: "default", numberOfLines: 1, textBreakStrategy: "simple", multiline: false, placeholder: placeholder, placeholderTextColor: colors.textPlaceholder, right: rightIcon, onFocus: onFocus, autoFocus: autoFocus, onBlur: onBlur, allowFontScaling: false, onChangeText: debouncedOnChangeText, style: [
|
|
7247
7209
|
{
|
|
7248
7210
|
height: height || 36,
|
|
7249
7211
|
},
|