sapo-components-ui-rn 1.0.52 → 1.0.53
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/Avatar/index.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +1 -0
- package/dist/components/TextInput/TextInputFlat.d.ts +1 -1
- package/dist/components/TextInput/types.d.ts +1 -0
- package/dist/index.esm.js +261 -234
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +261 -234
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Avatar/index.tsx +3 -3
- package/src/components/TextInput/TextInput.tsx +1 -0
- package/src/components/TextInput/TextInputDefault.tsx +11 -5
- package/src/components/TextInput/TextInputFlat.tsx +95 -45
- package/src/components/TextInput/types.tsx +1 -0
- package/src/icons/IconError.tsx +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { ChildTextInputProps } from "./types";
|
|
3
|
-
declare const TextInputFlat: ({ disabled, editable, label, error, selectionColor: customSelectionColor, cursorColor, underlineColor, underlineStyle, activeUnderlineColor, textColor, dense, style, theme, render, multiline, parentState, innerRef, onFocus, forceFocus, onBlur, onChangeText, onLayoutAnimatedText, onLabelTextLayout, onLeftAffixLayoutChange, onRightAffixLayoutChange, onInputLayout, left, right, placeholderTextColor, clearButton, contentStyle, scaledLabel, outlineStyle, outlineColor, value, ...rest }: ChildTextInputProps) => React.JSX.Element;
|
|
3
|
+
declare const TextInputFlat: ({ disabled, editable, label, error, selectionColor: customSelectionColor, cursorColor, underlineColor, underlineStyle, activeUnderlineColor, textColor, dense, style, theme, render, multiline, parentState, innerRef, onFocus, forceFocus, onBlur, onChangeText, onLayoutAnimatedText, onLabelTextLayout, onLeftAffixLayoutChange, onRightAffixLayoutChange, onInputLayout, left, right, prefix, placeholderTextColor, clearButton, contentStyle, scaledLabel, outlineStyle, outlineColor, value, ...rest }: ChildTextInputProps) => React.JSX.Element;
|
|
4
4
|
export default TextInputFlat;
|
|
@@ -93,6 +93,7 @@ export type ChildTextInputProps = {
|
|
|
93
93
|
onLeftAffixLayoutChange: (event: LayoutChangeEvent) => void;
|
|
94
94
|
onRightAffixLayoutChange: (event: LayoutChangeEvent) => void;
|
|
95
95
|
clearButton?: boolean;
|
|
96
|
+
prefix?: string;
|
|
96
97
|
} & $Omit<TextInputTypesWithoutMode, "theme"> & {
|
|
97
98
|
theme: InternalTheme;
|
|
98
99
|
};
|
package/dist/index.esm.js
CHANGED
|
@@ -2877,233 +2877,6 @@ var Icon = function (_a) {
|
|
|
2877
2877
|
};
|
|
2878
2878
|
var Icon$1 = React__default.memo(Icon);
|
|
2879
2879
|
|
|
2880
|
-
var TextInputFlat = function (_a) {
|
|
2881
|
-
var _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.editable, editable = _c === void 0 ? true : _c, label = _a.label, _d = _a.error, error = _d === void 0 ? false : _d, customSelectionColor = _a.selectionColor, cursorColor = _a.cursorColor, underlineColor = _a.underlineColor; _a.underlineStyle; var activeUnderlineColor = _a.activeUnderlineColor, textColor = _a.textColor, dense = _a.dense, style = _a.style, theme = _a.theme, _e = _a.render, render = _e === void 0 ? function (props) { return React$3.createElement(TextInput$1, __assign({}, props)); } : _e, _f = _a.multiline, multiline = _f === void 0 ? false : _f, parentState = _a.parentState, innerRef = _a.innerRef, onFocus = _a.onFocus; _a.forceFocus; var onBlur = _a.onBlur, onChangeText = _a.onChangeText, onLayoutAnimatedText = _a.onLayoutAnimatedText, onLabelTextLayout = _a.onLabelTextLayout; _a.onLeftAffixLayoutChange; _a.onRightAffixLayoutChange; var onInputLayout = _a.onInputLayout, left = _a.left, right = _a.right, placeholderTextColor = _a.placeholderTextColor, clearButton = _a.clearButton, contentStyle = _a.contentStyle, scaledLabel = _a.scaledLabel, outlineStyle = _a.outlineStyle, outlineColor = _a.outlineColor, value = _a.value, rest = __rest(_a, ["disabled", "editable", "label", "error", "selectionColor", "cursorColor", "underlineColor", "underlineStyle", "activeUnderlineColor", "textColor", "dense", "style", "theme", "render", "multiline", "parentState", "innerRef", "onFocus", "forceFocus", "onBlur", "onChangeText", "onLayoutAnimatedText", "onLabelTextLayout", "onLeftAffixLayoutChange", "onRightAffixLayoutChange", "onInputLayout", "left", "right", "placeholderTextColor", "clearButton", "contentStyle", "scaledLabel", "outlineStyle", "outlineColor", "value"]);
|
|
2882
|
-
var _g = React$3.useState(value || ""), inputValue = _g[0], setInputValue = _g[1];
|
|
2883
|
-
React$3.useEffect(function () {
|
|
2884
|
-
setInputValue(value || "");
|
|
2885
|
-
}, [value]);
|
|
2886
|
-
var handleChangeText = function (text) {
|
|
2887
|
-
setInputValue(text);
|
|
2888
|
-
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(text);
|
|
2889
|
-
};
|
|
2890
|
-
var handleClear = function () {
|
|
2891
|
-
setInputValue("");
|
|
2892
|
-
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText("");
|
|
2893
|
-
};
|
|
2894
|
-
var isAndroid = Platform.OS === "android";
|
|
2895
|
-
var roundness = theme.roundness;
|
|
2896
|
-
var font = theme.fonts.bodyLarge;
|
|
2897
|
-
var hasActiveOutline = parentState.focused || error;
|
|
2898
|
-
var _h = getConstants(), LABEL_PADDING_TOP = _h.LABEL_PADDING_TOP, FLAT_INPUT_OFFSET = _h.FLAT_INPUT_OFFSET, MIN_HEIGHT = _h.MIN_HEIGHT;
|
|
2899
|
-
var _j = (StyleSheet.flatten(style) || {}), fontSizeStyle = _j.fontSize, lineHeightStyle = _j.lineHeight, fontWeight = _j.fontWeight, height = _j.height, paddingHorizontal = _j.paddingHorizontal, textAlign = _j.textAlign; __rest(_j, ["fontSize", "lineHeight", "fontWeight", "height", "paddingHorizontal", "textAlign"]);
|
|
2900
|
-
var fontSize = fontSizeStyle || MAXIMIZED_LABEL_FONT_SIZE;
|
|
2901
|
-
var lineHeight = lineHeightStyle || (Platform.OS === "web" ? fontSize * 1.2 : undefined);
|
|
2902
|
-
var isPaddingHorizontalPassed = paddingHorizontal !== undefined && typeof paddingHorizontal === "number";
|
|
2903
|
-
var adornmentConfig = getAdornmentConfig({
|
|
2904
|
-
left: left,
|
|
2905
|
-
right: right,
|
|
2906
|
-
});
|
|
2907
|
-
var _k = calculateFlatInputHorizontalPadding({
|
|
2908
|
-
adornmentConfig: adornmentConfig,
|
|
2909
|
-
}), paddingLeft = _k.paddingLeft, paddingRight = _k.paddingRight;
|
|
2910
|
-
if (isPaddingHorizontalPassed) {
|
|
2911
|
-
paddingLeft = paddingHorizontal;
|
|
2912
|
-
paddingRight = paddingHorizontal;
|
|
2913
|
-
}
|
|
2914
|
-
var _l = getFlatInputColors({
|
|
2915
|
-
underlineColor: underlineColor,
|
|
2916
|
-
activeUnderlineColor: activeUnderlineColor,
|
|
2917
|
-
customSelectionColor: customSelectionColor,
|
|
2918
|
-
textColor: textColor,
|
|
2919
|
-
disabled: disabled,
|
|
2920
|
-
error: error,
|
|
2921
|
-
theme: theme,
|
|
2922
|
-
}), inputTextColor = _l.inputTextColor, activeColor = _l.activeColor, placeholderColor = _l.placeholderColor, errorColor = _l.errorColor, backgroundColor = _l.backgroundColor, selectionColor = _l.selectionColor;
|
|
2923
|
-
({
|
|
2924
|
-
backgroundColor: backgroundColor,
|
|
2925
|
-
borderTopLeftRadius: theme.roundness,
|
|
2926
|
-
borderTopRightRadius: theme.roundness,
|
|
2927
|
-
});
|
|
2928
|
-
var labelScale = MINIMIZED_LABEL_FONT_SIZE / fontSize;
|
|
2929
|
-
var fontScale = MAXIMIZED_LABEL_FONT_SIZE / fontSize;
|
|
2930
|
-
var labelWidth = parentState.labelLayout.width;
|
|
2931
|
-
var labelHeight = parentState.labelLayout.height;
|
|
2932
|
-
var labelHalfWidth = labelWidth / 2;
|
|
2933
|
-
var labelHalfHeight = labelHeight / 2;
|
|
2934
|
-
var baseLabelTranslateX = (I18nManager.getConstants().isRTL ? 1 : -1) *
|
|
2935
|
-
(labelHalfWidth - (labelScale * labelWidth) / 2) +
|
|
2936
|
-
(1 - labelScale) *
|
|
2937
|
-
(I18nManager.getConstants().isRTL ? -1 : 1) *
|
|
2938
|
-
paddingLeft;
|
|
2939
|
-
var minInputHeight = dense
|
|
2940
|
-
? (label ? MIN_DENSE_HEIGHT_WL : MIN_DENSE_HEIGHT) - LABEL_PADDING_TOP_DENSE
|
|
2941
|
-
: MIN_HEIGHT - LABEL_PADDING_TOP;
|
|
2942
|
-
var inputHeight = calculateInputHeight(labelHeight, height, minInputHeight);
|
|
2943
|
-
var topPosition = calculateLabelTopPosition(labelHeight, inputHeight, multiline && height ? 0 : !height ? minInputHeight / 2 : 0);
|
|
2944
|
-
if (height && typeof height !== "number") {
|
|
2945
|
-
// eslint-disable-next-line
|
|
2946
|
-
console.warn("Currently we support only numbers in height prop");
|
|
2947
|
-
}
|
|
2948
|
-
var paddingSettings = {
|
|
2949
|
-
height: height ? +height : null,
|
|
2950
|
-
labelHalfHeight: labelHalfHeight,
|
|
2951
|
-
offset: FLAT_INPUT_OFFSET,
|
|
2952
|
-
multiline: multiline ? multiline : null,
|
|
2953
|
-
dense: dense ? dense : null,
|
|
2954
|
-
topPosition: topPosition,
|
|
2955
|
-
fontSize: fontSize,
|
|
2956
|
-
lineHeight: lineHeight,
|
|
2957
|
-
label: label,
|
|
2958
|
-
scale: fontScale,
|
|
2959
|
-
isAndroid: isAndroid,
|
|
2960
|
-
styles: StyleSheet.flatten(dense ? styles$b.inputFlatDense : styles$b.inputFlat),
|
|
2961
|
-
};
|
|
2962
|
-
var pad = calculatePadding(paddingSettings);
|
|
2963
|
-
adjustPaddingFlat(__assign(__assign({}, paddingSettings), { pad: pad }));
|
|
2964
|
-
var baseLabelTranslateY = -labelHalfHeight - (topPosition + MINIMIZED_LABEL_Y_OFFSET);
|
|
2965
|
-
var placeholderOpacityAnims = React$3.useRef([
|
|
2966
|
-
new Animated.Value(0),
|
|
2967
|
-
new Animated.Value(1),
|
|
2968
|
-
]).current;
|
|
2969
|
-
var placeholderOpacity = hasActiveOutline
|
|
2970
|
-
? parentState.labeled
|
|
2971
|
-
: placeholderOpacityAnims[parentState.labelLayout.measured ? 1 : 0];
|
|
2972
|
-
// We don't want to show placeholder if label is displayed, because they overlap.
|
|
2973
|
-
// Before it was done by setting placeholder's value to " ", but inputs have the same props
|
|
2974
|
-
// what causes broken styles due to: https://github.com/facebook/react-native/issues/48249
|
|
2975
|
-
var placeholderTextColorBasedOnState = parentState.displayPlaceholder
|
|
2976
|
-
? placeholderTextColor !== null && placeholderTextColor !== void 0 ? placeholderTextColor : placeholderColor
|
|
2977
|
-
: "transparent";
|
|
2978
|
-
var minHeight = height ||
|
|
2979
|
-
(dense ? (label ? MIN_DENSE_HEIGHT_WL : MIN_DENSE_HEIGHT) : MIN_HEIGHT);
|
|
2980
|
-
var labelProps = {
|
|
2981
|
-
label: label,
|
|
2982
|
-
onLayoutAnimatedText: onLayoutAnimatedText,
|
|
2983
|
-
onLabelTextLayout: onLabelTextLayout,
|
|
2984
|
-
placeholderOpacity: placeholderOpacity,
|
|
2985
|
-
labelError: error,
|
|
2986
|
-
placeholderStyle: styles$b.placeholder,
|
|
2987
|
-
baseLabelTranslateY: baseLabelTranslateY,
|
|
2988
|
-
baseLabelTranslateX: baseLabelTranslateX,
|
|
2989
|
-
font: font,
|
|
2990
|
-
fontSize: fontSize,
|
|
2991
|
-
lineHeight: lineHeight,
|
|
2992
|
-
fontWeight: fontWeight,
|
|
2993
|
-
labelScale: labelScale,
|
|
2994
|
-
wiggleOffsetX: LABEL_WIGGLE_X_OFFSET,
|
|
2995
|
-
topPosition: topPosition,
|
|
2996
|
-
paddingLeft: isAndroid
|
|
2997
|
-
? I18nManager.isRTL
|
|
2998
|
-
? paddingRight
|
|
2999
|
-
: paddingLeft
|
|
3000
|
-
: paddingLeft,
|
|
3001
|
-
paddingRight: isAndroid
|
|
3002
|
-
? I18nManager.isRTL
|
|
3003
|
-
? paddingLeft
|
|
3004
|
-
: paddingRight
|
|
3005
|
-
: paddingRight,
|
|
3006
|
-
hasActiveOutline: hasActiveOutline,
|
|
3007
|
-
activeColor: activeColor,
|
|
3008
|
-
placeholderColor: placeholderColor,
|
|
3009
|
-
errorColor: errorColor,
|
|
3010
|
-
roundness: roundness,
|
|
3011
|
-
maxFontSizeMultiplier: rest.maxFontSizeMultiplier,
|
|
3012
|
-
contentStyle: contentStyle,
|
|
3013
|
-
inputContainerLayout: parentState.inputContainerLayout,
|
|
3014
|
-
labelTextLayout: parentState.labelTextLayout,
|
|
3015
|
-
opacity: parentState.value || parentState.focused
|
|
3016
|
-
? parentState.labelLayout.measured
|
|
3017
|
-
? 1
|
|
3018
|
-
: 0
|
|
3019
|
-
: 1,
|
|
3020
|
-
};
|
|
3021
|
-
var getBorderColor = function () {
|
|
3022
|
-
if (disabled) {
|
|
3023
|
-
return theme.colors.surfacePrimaryDisabled;
|
|
3024
|
-
}
|
|
3025
|
-
else if (parentState.focused) {
|
|
3026
|
-
return activeColor;
|
|
3027
|
-
}
|
|
3028
|
-
else {
|
|
3029
|
-
return theme.colors.borderPrimaryDefault;
|
|
3030
|
-
}
|
|
3031
|
-
};
|
|
3032
|
-
return (React$3.createElement(View$1, { style: {
|
|
3033
|
-
flexDirection: "row",
|
|
3034
|
-
alignItems: "center",
|
|
3035
|
-
borderRadius: BORDER_RADIUS_6,
|
|
3036
|
-
borderWidth: 1,
|
|
3037
|
-
borderColor: getBorderColor(),
|
|
3038
|
-
height: 44,
|
|
3039
|
-
overflow: "hidden",
|
|
3040
|
-
backgroundColor: disabled
|
|
3041
|
-
? theme.colors.surfacePrimaryDisabled
|
|
3042
|
-
: theme.colors.surfacePrimaryDefault,
|
|
3043
|
-
} },
|
|
3044
|
-
React$3.createElement(View$1, { style: { flexDirection: "row" } },
|
|
3045
|
-
left && React$3.createElement(View$1, { style: { paddingLeft: SPACE_12 } }, left),
|
|
3046
|
-
left ? React$3.createElement(Spacer, { width: SPACE_8 }) : React$3.createElement(Spacer, { width: SPACE_12 })),
|
|
3047
|
-
React$3.createElement(Outline, { style: outlineStyle, label: label, roundness: roundness, hasActiveOutline: hasActiveOutline, focused: parentState.focused, activeColor: activeColor, outlineColor: outlineColor, backgroundColor: backgroundColor }),
|
|
3048
|
-
React$3.createElement(View$1, { onLayout: onInputLayout, style: [
|
|
3049
|
-
styles$b.labelContainer,
|
|
3050
|
-
{
|
|
3051
|
-
minHeight: minHeight,
|
|
3052
|
-
flex: 1,
|
|
3053
|
-
},
|
|
3054
|
-
] },
|
|
3055
|
-
label ? (React$3.createElement(InputLabel$1, __assign({ labeled: parentState.labeled, error: parentState.error, focused: parentState.focused, scaledLabel: scaledLabel, wiggle: Boolean(parentState.value && labelProps.labelError), labelLayoutMeasured: parentState.labelLayout.measured, labelLayoutWidth: parentState.labelLayout.width, labelLayoutHeight: parentState.labelLayout.height }, labelProps))) : null, render === null || render === void 0 ? void 0 :
|
|
3056
|
-
render(__assign(__assign({}, rest), { ref: innerRef, onChangeText: handleChangeText, value: inputValue, placeholder: rest.placeholder, editable: !disabled && editable, selectionColor: selectionColor, cursorColor: typeof cursorColor === "undefined" ? activeColor : cursorColor, placeholderTextColor: placeholderTextColorBasedOnState, onFocus: onFocus, onBlur: onBlur, underlineColorAndroid: "transparent", multiline: multiline, style: [
|
|
3057
|
-
styles$b.input,
|
|
3058
|
-
__assign(__assign({ paddingLeft: paddingLeft, paddingRight: paddingRight, paddingTop: parentState.focused || parentState.value ? SPACE_12 : 0 }, font), { fontSize: fontSize, lineHeight: lineHeight, fontWeight: fontWeight, color: inputTextColor, textAlignVertical: multiline ? "top" : "center", textAlign: textAlign
|
|
3059
|
-
? textAlign
|
|
3060
|
-
: I18nManager.getConstants().isRTL
|
|
3061
|
-
? "right"
|
|
3062
|
-
: "left", marginTop: Platform.OS === "android" ? SPACE_8 : 0 }),
|
|
3063
|
-
contentStyle,
|
|
3064
|
-
] }))),
|
|
3065
|
-
!disabled && clearButton && inputValue ? (React$3.createElement(TouchableOpacity, { onPress: handleClear, style: styles$b.clearButton },
|
|
3066
|
-
React$3.createElement(Icon$1, { name: "IconClearText", type: "Svg", size: 24 }))) : (React$3.createElement(Spacer, { width: SPACE_12 })),
|
|
3067
|
-
React$3.createElement(View$1, { style: { flexDirection: "row" } },
|
|
3068
|
-
right && React$3.createElement(Spacer, { width: SPACE_8 }),
|
|
3069
|
-
right && React$3.createElement(View$1, { style: { paddingRight: SPACE_12 } }, right))));
|
|
3070
|
-
};
|
|
3071
|
-
var styles$b = StyleSheet.create({
|
|
3072
|
-
placeholder: {
|
|
3073
|
-
position: "absolute",
|
|
3074
|
-
left: 0,
|
|
3075
|
-
},
|
|
3076
|
-
labelContainer: {
|
|
3077
|
-
paddingTop: 0,
|
|
3078
|
-
paddingBottom: 0,
|
|
3079
|
-
// flex: 1,
|
|
3080
|
-
},
|
|
3081
|
-
input: {
|
|
3082
|
-
// margin: 0,
|
|
3083
|
-
flex: 1,
|
|
3084
|
-
height: 44,
|
|
3085
|
-
},
|
|
3086
|
-
inputFlat: {
|
|
3087
|
-
paddingTop: 24,
|
|
3088
|
-
paddingBottom: 4,
|
|
3089
|
-
},
|
|
3090
|
-
inputFlatDense: {
|
|
3091
|
-
paddingTop: 22,
|
|
3092
|
-
paddingBottom: 2,
|
|
3093
|
-
},
|
|
3094
|
-
patchContainer: {
|
|
3095
|
-
height: 24,
|
|
3096
|
-
zIndex: 2,
|
|
3097
|
-
},
|
|
3098
|
-
densePatchContainer: {
|
|
3099
|
-
height: 22,
|
|
3100
|
-
zIndex: 2,
|
|
3101
|
-
},
|
|
3102
|
-
clearButton: {
|
|
3103
|
-
padding: SPACE_8,
|
|
3104
|
-
},
|
|
3105
|
-
});
|
|
3106
|
-
|
|
3107
2880
|
/**
|
|
3108
2881
|
* Removes all key-value entries from the list cache.
|
|
3109
2882
|
*
|
|
@@ -5608,6 +5381,256 @@ var Text = function (props) {
|
|
|
5608
5381
|
};
|
|
5609
5382
|
var Text$1 = memoDeepEqual(Text);
|
|
5610
5383
|
|
|
5384
|
+
var TextInputFlat = function (_a) {
|
|
5385
|
+
var _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.editable, editable = _c === void 0 ? true : _c, label = _a.label, _d = _a.error, error = _d === void 0 ? false : _d, customSelectionColor = _a.selectionColor, cursorColor = _a.cursorColor, underlineColor = _a.underlineColor; _a.underlineStyle; var activeUnderlineColor = _a.activeUnderlineColor, textColor = _a.textColor, dense = _a.dense, style = _a.style, theme = _a.theme, _e = _a.render, render = _e === void 0 ? function (props) { return React$3.createElement(TextInput$1, __assign({}, props)); } : _e, _f = _a.multiline, multiline = _f === void 0 ? false : _f, parentState = _a.parentState, innerRef = _a.innerRef, onFocus = _a.onFocus; _a.forceFocus; var onBlur = _a.onBlur, onChangeText = _a.onChangeText, onLayoutAnimatedText = _a.onLayoutAnimatedText, onLabelTextLayout = _a.onLabelTextLayout; _a.onLeftAffixLayoutChange; _a.onRightAffixLayoutChange; var onInputLayout = _a.onInputLayout, left = _a.left, right = _a.right, prefix = _a.prefix, placeholderTextColor = _a.placeholderTextColor, clearButton = _a.clearButton, contentStyle = _a.contentStyle, scaledLabel = _a.scaledLabel, outlineStyle = _a.outlineStyle, outlineColor = _a.outlineColor, value = _a.value, rest = __rest(_a, ["disabled", "editable", "label", "error", "selectionColor", "cursorColor", "underlineColor", "underlineStyle", "activeUnderlineColor", "textColor", "dense", "style", "theme", "render", "multiline", "parentState", "innerRef", "onFocus", "forceFocus", "onBlur", "onChangeText", "onLayoutAnimatedText", "onLabelTextLayout", "onLeftAffixLayoutChange", "onRightAffixLayoutChange", "onInputLayout", "left", "right", "prefix", "placeholderTextColor", "clearButton", "contentStyle", "scaledLabel", "outlineStyle", "outlineColor", "value"]);
|
|
5386
|
+
var _g = React$3.useState(value || ""), inputValue = _g[0], setInputValue = _g[1];
|
|
5387
|
+
React$3.useEffect(function () {
|
|
5388
|
+
setInputValue(value || "");
|
|
5389
|
+
}, [value]);
|
|
5390
|
+
var handleChangeText = function (text) {
|
|
5391
|
+
setInputValue(text);
|
|
5392
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(text);
|
|
5393
|
+
};
|
|
5394
|
+
var handleClear = function () {
|
|
5395
|
+
setInputValue("");
|
|
5396
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText("");
|
|
5397
|
+
};
|
|
5398
|
+
var isAndroid = Platform.OS === "android";
|
|
5399
|
+
var roundness = theme.roundness;
|
|
5400
|
+
var font = theme.fonts.bodyLarge;
|
|
5401
|
+
var hasActiveOutline = parentState.focused || error;
|
|
5402
|
+
var _h = getConstants(), LABEL_PADDING_TOP = _h.LABEL_PADDING_TOP, FLAT_INPUT_OFFSET = _h.FLAT_INPUT_OFFSET, MIN_HEIGHT = _h.MIN_HEIGHT;
|
|
5403
|
+
var _j = (StyleSheet.flatten(style) || {}), fontSizeStyle = _j.fontSize, lineHeightStyle = _j.lineHeight, fontWeight = _j.fontWeight, height = _j.height, paddingHorizontal = _j.paddingHorizontal, textAlign = _j.textAlign; __rest(_j, ["fontSize", "lineHeight", "fontWeight", "height", "paddingHorizontal", "textAlign"]);
|
|
5404
|
+
var fontSize = fontSizeStyle || MAXIMIZED_LABEL_FONT_SIZE;
|
|
5405
|
+
var lineHeight = lineHeightStyle || (Platform.OS === "web" ? fontSize * 1.2 : undefined);
|
|
5406
|
+
var isPaddingHorizontalPassed = paddingHorizontal !== undefined && typeof paddingHorizontal === "number";
|
|
5407
|
+
var adornmentConfig = getAdornmentConfig({
|
|
5408
|
+
left: left,
|
|
5409
|
+
right: right,
|
|
5410
|
+
});
|
|
5411
|
+
var _k = calculateFlatInputHorizontalPadding({
|
|
5412
|
+
adornmentConfig: adornmentConfig,
|
|
5413
|
+
}), paddingLeft = _k.paddingLeft, paddingRight = _k.paddingRight;
|
|
5414
|
+
if (isPaddingHorizontalPassed) {
|
|
5415
|
+
paddingLeft = paddingHorizontal;
|
|
5416
|
+
paddingRight = paddingHorizontal;
|
|
5417
|
+
}
|
|
5418
|
+
var _l = getFlatInputColors({
|
|
5419
|
+
underlineColor: underlineColor,
|
|
5420
|
+
activeUnderlineColor: activeUnderlineColor,
|
|
5421
|
+
customSelectionColor: customSelectionColor,
|
|
5422
|
+
textColor: textColor,
|
|
5423
|
+
disabled: disabled,
|
|
5424
|
+
error: error,
|
|
5425
|
+
theme: theme,
|
|
5426
|
+
}), inputTextColor = _l.inputTextColor, activeColor = _l.activeColor, placeholderColor = _l.placeholderColor, errorColor = _l.errorColor, backgroundColor = _l.backgroundColor, selectionColor = _l.selectionColor;
|
|
5427
|
+
({
|
|
5428
|
+
backgroundColor: backgroundColor,
|
|
5429
|
+
borderTopLeftRadius: theme.roundness,
|
|
5430
|
+
borderTopRightRadius: theme.roundness,
|
|
5431
|
+
});
|
|
5432
|
+
var labelScale = MINIMIZED_LABEL_FONT_SIZE / fontSize;
|
|
5433
|
+
var fontScale = MAXIMIZED_LABEL_FONT_SIZE / fontSize;
|
|
5434
|
+
var labelWidth = parentState.labelLayout.width;
|
|
5435
|
+
var labelHeight = parentState.labelLayout.height;
|
|
5436
|
+
var labelHalfWidth = labelWidth / 2;
|
|
5437
|
+
var labelHalfHeight = labelHeight / 2;
|
|
5438
|
+
var baseLabelTranslateX = (I18nManager.getConstants().isRTL ? 1 : -1) *
|
|
5439
|
+
(labelHalfWidth - (labelScale * labelWidth) / 2) +
|
|
5440
|
+
(1 - labelScale) *
|
|
5441
|
+
(I18nManager.getConstants().isRTL ? -1 : 1) *
|
|
5442
|
+
paddingLeft;
|
|
5443
|
+
var minInputHeight = dense
|
|
5444
|
+
? (label ? MIN_DENSE_HEIGHT_WL : MIN_DENSE_HEIGHT) - LABEL_PADDING_TOP_DENSE
|
|
5445
|
+
: MIN_HEIGHT - LABEL_PADDING_TOP;
|
|
5446
|
+
var inputHeight = calculateInputHeight(labelHeight, height, minInputHeight);
|
|
5447
|
+
var topPosition = calculateLabelTopPosition(labelHeight, inputHeight, multiline && height ? 0 : !height ? minInputHeight / 2 : 0);
|
|
5448
|
+
if (height && typeof height !== "number") {
|
|
5449
|
+
// eslint-disable-next-line
|
|
5450
|
+
console.warn("Currently we support only numbers in height prop");
|
|
5451
|
+
}
|
|
5452
|
+
var paddingSettings = {
|
|
5453
|
+
height: height ? +height : null,
|
|
5454
|
+
labelHalfHeight: labelHalfHeight,
|
|
5455
|
+
offset: FLAT_INPUT_OFFSET,
|
|
5456
|
+
multiline: multiline ? multiline : null,
|
|
5457
|
+
dense: dense ? dense : null,
|
|
5458
|
+
topPosition: topPosition,
|
|
5459
|
+
fontSize: fontSize,
|
|
5460
|
+
lineHeight: lineHeight,
|
|
5461
|
+
label: label,
|
|
5462
|
+
scale: fontScale,
|
|
5463
|
+
isAndroid: isAndroid,
|
|
5464
|
+
styles: StyleSheet.flatten(dense ? styles$b.inputFlatDense : styles$b.inputFlat),
|
|
5465
|
+
};
|
|
5466
|
+
var pad = calculatePadding(paddingSettings);
|
|
5467
|
+
adjustPaddingFlat(__assign(__assign({}, paddingSettings), { pad: pad }));
|
|
5468
|
+
var baseLabelTranslateY = -labelHalfHeight - (topPosition + MINIMIZED_LABEL_Y_OFFSET);
|
|
5469
|
+
var placeholderOpacityAnims = React$3.useRef([
|
|
5470
|
+
new Animated.Value(0),
|
|
5471
|
+
new Animated.Value(1),
|
|
5472
|
+
]).current;
|
|
5473
|
+
var placeholderOpacity = hasActiveOutline
|
|
5474
|
+
? parentState.labeled
|
|
5475
|
+
: placeholderOpacityAnims[parentState.labelLayout.measured ? 1 : 0];
|
|
5476
|
+
// We don't want to show placeholder if label is displayed, because they overlap.
|
|
5477
|
+
// Before it was done by setting placeholder's value to " ", but inputs have the same props
|
|
5478
|
+
// what causes broken styles due to: https://github.com/facebook/react-native/issues/48249
|
|
5479
|
+
var placeholderTextColorBasedOnState = parentState.displayPlaceholder
|
|
5480
|
+
? placeholderTextColor !== null && placeholderTextColor !== void 0 ? placeholderTextColor : placeholderColor
|
|
5481
|
+
: "transparent";
|
|
5482
|
+
var minHeight = height ||
|
|
5483
|
+
(dense ? (label ? MIN_DENSE_HEIGHT_WL : MIN_DENSE_HEIGHT) : MIN_HEIGHT);
|
|
5484
|
+
var labelProps = {
|
|
5485
|
+
label: label,
|
|
5486
|
+
onLayoutAnimatedText: onLayoutAnimatedText,
|
|
5487
|
+
onLabelTextLayout: onLabelTextLayout,
|
|
5488
|
+
placeholderOpacity: placeholderOpacity,
|
|
5489
|
+
labelError: error,
|
|
5490
|
+
placeholderStyle: styles$b.placeholder,
|
|
5491
|
+
baseLabelTranslateY: baseLabelTranslateY,
|
|
5492
|
+
baseLabelTranslateX: baseLabelTranslateX,
|
|
5493
|
+
font: font,
|
|
5494
|
+
fontSize: fontSize,
|
|
5495
|
+
lineHeight: lineHeight,
|
|
5496
|
+
fontWeight: fontWeight,
|
|
5497
|
+
labelScale: labelScale,
|
|
5498
|
+
wiggleOffsetX: LABEL_WIGGLE_X_OFFSET,
|
|
5499
|
+
topPosition: topPosition,
|
|
5500
|
+
paddingLeft: isAndroid
|
|
5501
|
+
? I18nManager.isRTL
|
|
5502
|
+
? paddingRight
|
|
5503
|
+
: paddingLeft
|
|
5504
|
+
: paddingLeft,
|
|
5505
|
+
paddingRight: isAndroid
|
|
5506
|
+
? I18nManager.isRTL
|
|
5507
|
+
? paddingLeft
|
|
5508
|
+
: paddingRight
|
|
5509
|
+
: paddingRight,
|
|
5510
|
+
hasActiveOutline: hasActiveOutline,
|
|
5511
|
+
activeColor: activeColor,
|
|
5512
|
+
placeholderColor: placeholderColor,
|
|
5513
|
+
errorColor: errorColor,
|
|
5514
|
+
roundness: roundness,
|
|
5515
|
+
maxFontSizeMultiplier: rest.maxFontSizeMultiplier,
|
|
5516
|
+
contentStyle: contentStyle,
|
|
5517
|
+
inputContainerLayout: parentState.inputContainerLayout,
|
|
5518
|
+
labelTextLayout: parentState.labelTextLayout,
|
|
5519
|
+
opacity: parentState.value || parentState.focused
|
|
5520
|
+
? parentState.labelLayout.measured
|
|
5521
|
+
? 1
|
|
5522
|
+
: 0
|
|
5523
|
+
: 1,
|
|
5524
|
+
};
|
|
5525
|
+
var getBorderColor = function () {
|
|
5526
|
+
if (disabled) {
|
|
5527
|
+
return theme.colors.surfacePrimaryDisabled;
|
|
5528
|
+
}
|
|
5529
|
+
else if (parentState.focused) {
|
|
5530
|
+
return activeColor;
|
|
5531
|
+
}
|
|
5532
|
+
else {
|
|
5533
|
+
return theme.colors.borderPrimaryDefault;
|
|
5534
|
+
}
|
|
5535
|
+
};
|
|
5536
|
+
var renderPrefix = function () {
|
|
5537
|
+
var _a;
|
|
5538
|
+
if (parentState.focused) {
|
|
5539
|
+
return (React$3.createElement(View$1, { style: {
|
|
5540
|
+
paddingBottom: Platform.OS === "ios" ? 9 : 13,
|
|
5541
|
+
} },
|
|
5542
|
+
React$3.createElement(Text$1, { color: theme.colors.textSecondary },
|
|
5543
|
+
prefix, " ")));
|
|
5544
|
+
}
|
|
5545
|
+
else if (parentState.value !== undefined &&
|
|
5546
|
+
((_a = parentState.value) === null || _a === void 0 ? void 0 : _a.toString()) !== "") {
|
|
5547
|
+
return (React$3.createElement(View$1, { style: {
|
|
5548
|
+
paddingBottom: Platform.OS === "ios" ? 9 : 13,
|
|
5549
|
+
} },
|
|
5550
|
+
React$3.createElement(Text$1, { color: theme.colors.textSecondary },
|
|
5551
|
+
prefix, " ")));
|
|
5552
|
+
}
|
|
5553
|
+
return React$3.createElement(View$1, null);
|
|
5554
|
+
};
|
|
5555
|
+
return (React$3.createElement(View$1, { style: {
|
|
5556
|
+
flexDirection: "row",
|
|
5557
|
+
alignItems: "center",
|
|
5558
|
+
borderRadius: BORDER_RADIUS_6,
|
|
5559
|
+
borderWidth: 1,
|
|
5560
|
+
borderColor: getBorderColor(),
|
|
5561
|
+
height: 48,
|
|
5562
|
+
overflow: "hidden",
|
|
5563
|
+
backgroundColor: disabled
|
|
5564
|
+
? theme.colors.surfacePrimaryDisabled
|
|
5565
|
+
: theme.colors.surfacePrimaryDefault,
|
|
5566
|
+
} },
|
|
5567
|
+
React$3.createElement(View$1, { style: { flexDirection: "row", height: "100%" } },
|
|
5568
|
+
left && React$3.createElement(View$1, { style: { paddingLeft: SPACE_12 } }, left),
|
|
5569
|
+
left ? React$3.createElement(Spacer, { width: SPACE_8 }) : React$3.createElement(Spacer, { width: SPACE_12 })),
|
|
5570
|
+
React$3.createElement(Outline, { style: outlineStyle, label: label, roundness: roundness, hasActiveOutline: hasActiveOutline, focused: parentState.focused, activeColor: activeColor, outlineColor: outlineColor, backgroundColor: backgroundColor }),
|
|
5571
|
+
React$3.createElement(View$1, { onLayout: onInputLayout, style: [
|
|
5572
|
+
styles$b.labelContainer,
|
|
5573
|
+
{
|
|
5574
|
+
minHeight: minHeight,
|
|
5575
|
+
flex: 1,
|
|
5576
|
+
},
|
|
5577
|
+
] },
|
|
5578
|
+
label ? (React$3.createElement(InputLabel$1, __assign({ labeled: parentState.labeled, error: parentState.error, focused: parentState.focused, scaledLabel: scaledLabel, wiggle: Boolean(parentState.value && labelProps.labelError), labelLayoutMeasured: parentState.labelLayout.measured, labelLayoutWidth: parentState.labelLayout.width, labelLayoutHeight: parentState.labelLayout.height }, labelProps))) : null,
|
|
5579
|
+
React$3.createElement(View$1, { style: { flexDirection: "row", alignItems: "flex-end" } },
|
|
5580
|
+
renderPrefix(), render === null || render === void 0 ? void 0 :
|
|
5581
|
+
render(__assign(__assign({}, rest), { ref: innerRef, onChangeText: handleChangeText, value: inputValue, placeholder: rest.placeholder, editable: !disabled && editable, selectionColor: selectionColor, cursorColor: typeof cursorColor === "undefined" ? activeColor : cursorColor, placeholderTextColor: placeholderTextColorBasedOnState, onFocus: onFocus, onBlur: onBlur, underlineColorAndroid: "transparent", multiline: multiline, style: [
|
|
5582
|
+
styles$b.input,
|
|
5583
|
+
__assign(__assign({ paddingLeft: paddingLeft, paddingRight: paddingRight, paddingTop: parentState.focused || parentState.value ? SPACE_12 : 0 }, font), { fontSize: fontSize, lineHeight: lineHeight, fontWeight: fontWeight, color: inputTextColor, textAlignVertical: multiline ? "top" : "center", textAlign: textAlign
|
|
5584
|
+
? textAlign
|
|
5585
|
+
: I18nManager.getConstants().isRTL
|
|
5586
|
+
? "right"
|
|
5587
|
+
: "left", marginTop: Platform.OS === "android" ? SPACE_8 : 0 }),
|
|
5588
|
+
contentStyle,
|
|
5589
|
+
] })))),
|
|
5590
|
+
!disabled && clearButton && inputValue ? (React$3.createElement(TouchableOpacity, { onPress: handleClear, style: styles$b.clearButton },
|
|
5591
|
+
React$3.createElement(Icon$1, { name: "IconClearText", type: "Svg", size: 24 }))) : (React$3.createElement(Spacer, { width: SPACE_12 })),
|
|
5592
|
+
React$3.createElement(View$1, { style: { flexDirection: "row", height: "100%", paddingBottom: SPACE_6 } },
|
|
5593
|
+
right && !clearButton && React$3.createElement(Spacer, { width: SPACE_8 }),
|
|
5594
|
+
right && (React$3.createElement(View$1, { style: {
|
|
5595
|
+
paddingRight: SPACE_12,
|
|
5596
|
+
} }, right)))));
|
|
5597
|
+
};
|
|
5598
|
+
var styles$b = StyleSheet.create({
|
|
5599
|
+
placeholder: {
|
|
5600
|
+
position: "absolute",
|
|
5601
|
+
left: 0,
|
|
5602
|
+
},
|
|
5603
|
+
labelContainer: {
|
|
5604
|
+
paddingTop: 0,
|
|
5605
|
+
paddingBottom: 0,
|
|
5606
|
+
// flex: 1,
|
|
5607
|
+
},
|
|
5608
|
+
input: {
|
|
5609
|
+
// margin: 0,
|
|
5610
|
+
flex: 1,
|
|
5611
|
+
height: 48,
|
|
5612
|
+
},
|
|
5613
|
+
inputFlat: {
|
|
5614
|
+
paddingTop: 24,
|
|
5615
|
+
paddingBottom: 4,
|
|
5616
|
+
},
|
|
5617
|
+
inputFlatDense: {
|
|
5618
|
+
paddingTop: 22,
|
|
5619
|
+
paddingBottom: 2,
|
|
5620
|
+
},
|
|
5621
|
+
patchContainer: {
|
|
5622
|
+
height: 24,
|
|
5623
|
+
zIndex: 2,
|
|
5624
|
+
},
|
|
5625
|
+
densePatchContainer: {
|
|
5626
|
+
height: 22,
|
|
5627
|
+
zIndex: 2,
|
|
5628
|
+
},
|
|
5629
|
+
clearButton: {
|
|
5630
|
+
padding: SPACE_8,
|
|
5631
|
+
},
|
|
5632
|
+
});
|
|
5633
|
+
|
|
5611
5634
|
var TextInputDefault = function (_a) {
|
|
5612
5635
|
var _b;
|
|
5613
5636
|
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, _j = _a.value, value = _j === void 0 ? "" : _j, 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"]);
|
|
@@ -5701,7 +5724,7 @@ var TextInputDefault = function (_a) {
|
|
|
5701
5724
|
left && React$3.createElement(Spacer, { width: CONSTANTS.SPACE_8 }),
|
|
5702
5725
|
React$3.createElement(View, { full: true, style: [
|
|
5703
5726
|
{
|
|
5704
|
-
height: height ||
|
|
5727
|
+
height: height || 48,
|
|
5705
5728
|
},
|
|
5706
5729
|
] },
|
|
5707
5730
|
multiline && renderLabel(), render === null || render === void 0 ? void 0 :
|
|
@@ -5715,19 +5738,23 @@ var TextInputDefault = function (_a) {
|
|
|
5715
5738
|
? textAlign
|
|
5716
5739
|
: I18nManager.getConstants().isRTL
|
|
5717
5740
|
? "right"
|
|
5718
|
-
: "left", height: height ? height :
|
|
5741
|
+
: "left", height: height ? height : 48, paddingTop: getPaddingTopValue(), paddingBottom: multiline ? CONSTANTS.SPACE_4 : 0 }),
|
|
5719
5742
|
contentStyle,
|
|
5720
5743
|
] }))),
|
|
5721
5744
|
!disabled && clearButton && inputValue ? (React$3.createElement(TouchableOpacity, { onPress: handleClear, style: multiline ? styles$a.clearButtonMultiline : styles$a.clearButton },
|
|
5722
5745
|
React$3.createElement(Icon$1, { name: "IconClearText", type: "Svg", size: 24 }))) : (React$3.createElement(Spacer, { width: CONSTANTS.SPACE_12 })),
|
|
5723
|
-
right && React$3.createElement(Spacer, { width: CONSTANTS.
|
|
5724
|
-
right && (React$3.createElement(View, {
|
|
5746
|
+
right && !clearButton && React$3.createElement(Spacer, { width: CONSTANTS.SPACE_2 }),
|
|
5747
|
+
right && (React$3.createElement(View, { style: {
|
|
5748
|
+
height: "100%",
|
|
5749
|
+
paddingBottom: CONSTANTS.SPACE_12,
|
|
5750
|
+
paddingRight: CONSTANTS.SPACE_12,
|
|
5751
|
+
} }, right)))));
|
|
5725
5752
|
};
|
|
5726
5753
|
var styles$a = StyleSheet.create({
|
|
5727
5754
|
input: {
|
|
5728
5755
|
margin: 0,
|
|
5729
5756
|
flex: 1,
|
|
5730
|
-
height:
|
|
5757
|
+
height: 48,
|
|
5731
5758
|
paddingLeft: 0,
|
|
5732
5759
|
// paddingTop: Platform.OS === "ios" ? CONSTANTS.SPACE_4 : CONSTANTS.SPACE_2,
|
|
5733
5760
|
},
|
|
@@ -6739,7 +6766,7 @@ var styles$3 = StyleSheet.create(__assign(__assign({}, containerStyles), { icon:
|
|
|
6739
6766
|
} }));
|
|
6740
6767
|
|
|
6741
6768
|
var Avatar = function (_a) {
|
|
6742
|
-
var children = _a.children, _b = _a.name, name = _b === void 0 ? "Sapo" : _b, backgroundColor = _a.backgroundColor, style = _a.style, textColor = _a.textColor, _c = _a.size, size = _c === void 0 ?
|
|
6769
|
+
var children = _a.children, _b = _a.name, name = _b === void 0 ? "Sapo" : _b, backgroundColor = _a.backgroundColor, style = _a.style, textColor = _a.textColor, _c = _a.size, size = _c === void 0 ? 32 : _c, source = _a.source, onPress = _a.onPress, textStyle = _a.textStyle, imageStyle = _a.imageStyle;
|
|
6743
6770
|
var theme = useInternalTheme();
|
|
6744
6771
|
var colors = theme.colors;
|
|
6745
6772
|
var getInitials = function (name) {
|
|
@@ -6758,7 +6785,7 @@ var Avatar = function (_a) {
|
|
|
6758
6785
|
return 28;
|
|
6759
6786
|
case 48:
|
|
6760
6787
|
return 20;
|
|
6761
|
-
case
|
|
6788
|
+
case 32:
|
|
6762
6789
|
return 16;
|
|
6763
6790
|
default:
|
|
6764
6791
|
return 16;
|