sapo-components-ui-rn 1.1.46 → 1.1.48

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.
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { StyleProp, TextInput as NativeTextInput, TextStyle, ViewStyle } from "react-native";
2
+ import { StyleProp, TextInput as NativeTextInput, TextStyle, ViewStyle, TextProps } from "react-native";
3
3
  import { Props as TextInputAffixProps } from "./Adornment/TextInputAffix";
4
4
  import type { RenderProps, TextInputLabelProp } from "./types";
5
5
  import type { ThemeProp } from "../../types";
@@ -15,6 +15,8 @@ export type Props = React.ComponentPropsWithRef<typeof NativeTextInput> & {
15
15
  type?: "integer" | "float";
16
16
  formatDecimal?: 1 | 2 | 3;
17
17
  required?: boolean;
18
+ labelScaleValue?: number;
19
+ labelStyle?: StyleProp<TextProps>;
18
20
  /**
19
21
  * If true, user won't be able to interact with the component.
20
22
  */
@@ -1,4 +1,4 @@
1
1
  import * as React from "react";
2
2
  import type { ChildTextInputProps } from "./types";
3
- declare const TextInputDefault: ({ disabled, editable, label, error, selectionColor: customSelectionColor, cursorColor, outlineColor: customOutlineColor, 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, ...rest }: ChildTextInputProps) => React.JSX.Element;
3
+ declare const TextInputDefault: ({ disabled, editable, label, error, selectionColor: customSelectionColor, cursorColor, outlineColor: customOutlineColor, activeOutlineColor, outlineStyle, textColor, dense, style, theme, render, multiline, parentState, innerRef, onFocus, forceFocus, onBlur, onChangeText, onLayout, left, right, prefix, suffix, placeholderTextColor, clearButton, contentStyle, labelStyle, value, textError, required, ...rest }: ChildTextInputProps) => React.JSX.Element;
4
4
  export default TextInputDefault;
@@ -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, prefix, suffix, placeholderTextColor, clearButton, contentStyle, scaledLabel, outlineStyle, outlineColor, value, textError, required, ...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, suffix, placeholderTextColor, clearButton, contentStyle, scaledLabel, outlineStyle, outlineColor, value, textError, required, labelScaleValue, ...rest }: ChildTextInputProps) => React.JSX.Element;
4
4
  export default TextInputFlat;
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import type { TextInput as NativeTextInput, Animated, TextStyle, LayoutChangeEvent, ColorValue, StyleProp, ViewProps, ViewStyle, NativeSyntheticEvent, TextLayoutEventData } from "react-native";
2
+ import type { TextInput as NativeTextInput, Animated, TextStyle, LayoutChangeEvent, ColorValue, StyleProp, ViewProps, ViewStyle, NativeSyntheticEvent, TextLayoutEventData, TextProps } from "react-native";
3
3
  import type { $Omit, InternalTheme, ThemeProp } from "./../../types";
4
4
  export type TextInputLabelProp = string | React.ReactElement;
5
5
  type TextInputProps = React.ComponentPropsWithRef<typeof NativeTextInput> & {
@@ -79,6 +79,7 @@ export type State = {
79
79
  width: number;
80
80
  };
81
81
  contentStyle?: StyleProp<ViewProps>;
82
+ labelStyle?: StyleProp<TextProps>;
82
83
  };
83
84
  export type ChildTextInputProps = {
84
85
  parentState: State;
@@ -97,6 +98,8 @@ export type ChildTextInputProps = {
97
98
  suffix?: string;
98
99
  textError?: string;
99
100
  required?: boolean;
101
+ labelStyle?: StyleProp<TextProps>;
102
+ labelScaleValue?: number;
100
103
  } & $Omit<TextInputTypesWithoutMode, "theme"> & {
101
104
  theme: InternalTheme;
102
105
  };
package/dist/index.esm.js CHANGED
@@ -5084,8 +5084,8 @@ var SvgIcon = function (_a) {
5084
5084
  };
5085
5085
 
5086
5086
  var TextInputFlat = function (_a) {
5087
- 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, suffix = _a.suffix, placeholderTextColor = _a.placeholderTextColor, clearButton = _a.clearButton, contentStyle = _a.contentStyle, scaledLabel = _a.scaledLabel, outlineStyle = _a.outlineStyle, outlineColor = _a.outlineColor, value = _a.value, textError = _a.textError, required = _a.required, 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", "suffix", "placeholderTextColor", "clearButton", "contentStyle", "scaledLabel", "outlineStyle", "outlineColor", "value", "textError", "required"]);
5088
- var _g = React$3.useState(value || ""), inputValue = _g[0], setInputValue = _g[1];
5087
+ 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, suffix = _a.suffix, placeholderTextColor = _a.placeholderTextColor, clearButton = _a.clearButton, contentStyle = _a.contentStyle, scaledLabel = _a.scaledLabel, outlineStyle = _a.outlineStyle, outlineColor = _a.outlineColor, value = _a.value, textError = _a.textError, required = _a.required, _g = _a.labelScaleValue, labelScaleValue = _g === void 0 ? MINIMIZED_LABEL_FONT_SIZE : _g, 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", "suffix", "placeholderTextColor", "clearButton", "contentStyle", "scaledLabel", "outlineStyle", "outlineColor", "value", "textError", "required", "labelScaleValue"]);
5088
+ var _h = React$3.useState(value || ""), inputValue = _h[0], setInputValue = _h[1];
5089
5089
  React$3.useEffect(function () {
5090
5090
  if (value === undefined) {
5091
5091
  setInputValue("");
@@ -5107,8 +5107,8 @@ var TextInputFlat = function (_a) {
5107
5107
  var roundness = theme.roundness;
5108
5108
  var font = theme.fonts.bodyLarge;
5109
5109
  var hasActiveOutline = parentState.focused || error;
5110
- var _h = getConstants(), LABEL_PADDING_TOP = _h.LABEL_PADDING_TOP, FLAT_INPUT_OFFSET = _h.FLAT_INPUT_OFFSET, MIN_HEIGHT = _h.MIN_HEIGHT;
5111
- var _j = (StyleSheet.flatten(style) || {}), fontSizeStyle = _j.fontSize, lineHeightStyle = _j.lineHeight, fontWeight = _j.fontWeight, height = _j.height, paddingHorizontal = _j.paddingHorizontal; _j.textAlign; __rest(_j, ["fontSize", "lineHeight", "fontWeight", "height", "paddingHorizontal", "textAlign"]);
5110
+ var _j = getConstants(), LABEL_PADDING_TOP = _j.LABEL_PADDING_TOP, FLAT_INPUT_OFFSET = _j.FLAT_INPUT_OFFSET, MIN_HEIGHT = _j.MIN_HEIGHT;
5111
+ var _k = (StyleSheet.flatten(style) || {}), fontSizeStyle = _k.fontSize, lineHeightStyle = _k.lineHeight, fontWeight = _k.fontWeight, height = _k.height, paddingHorizontal = _k.paddingHorizontal; _k.textAlign; __rest(_k, ["fontSize", "lineHeight", "fontWeight", "height", "paddingHorizontal", "textAlign"]);
5112
5112
  var fontSize = fontSizeStyle || MAXIMIZED_LABEL_FONT_SIZE;
5113
5113
  var lineHeight = lineHeightStyle || (Platform.OS === "web" ? fontSize * 1.2 : undefined);
5114
5114
  var isPaddingHorizontalPassed = paddingHorizontal !== undefined && typeof paddingHorizontal === "number";
@@ -5116,14 +5116,14 @@ var TextInputFlat = function (_a) {
5116
5116
  left: left,
5117
5117
  right: right,
5118
5118
  });
5119
- var _k = calculateFlatInputHorizontalPadding({
5119
+ var _l = calculateFlatInputHorizontalPadding({
5120
5120
  adornmentConfig: adornmentConfig,
5121
- }), paddingLeft = _k.paddingLeft, paddingRight = _k.paddingRight;
5121
+ }), paddingLeft = _l.paddingLeft, paddingRight = _l.paddingRight;
5122
5122
  if (isPaddingHorizontalPassed) {
5123
5123
  paddingLeft = paddingHorizontal;
5124
5124
  paddingRight = paddingHorizontal;
5125
5125
  }
5126
- var _l = getFlatInputColors({
5126
+ var _m = getFlatInputColors({
5127
5127
  underlineColor: underlineColor,
5128
5128
  activeUnderlineColor: activeUnderlineColor,
5129
5129
  customSelectionColor: customSelectionColor,
@@ -5131,13 +5131,13 @@ var TextInputFlat = function (_a) {
5131
5131
  disabled: disabled,
5132
5132
  error: error,
5133
5133
  theme: theme,
5134
- }), inputTextColor = _l.inputTextColor, activeColor = _l.activeColor, placeholderColor = _l.placeholderColor, errorColor = _l.errorColor, backgroundColor = _l.backgroundColor, selectionColor = _l.selectionColor;
5134
+ }), inputTextColor = _m.inputTextColor, activeColor = _m.activeColor, placeholderColor = _m.placeholderColor, errorColor = _m.errorColor, backgroundColor = _m.backgroundColor, selectionColor = _m.selectionColor;
5135
5135
  ({
5136
5136
  backgroundColor: backgroundColor,
5137
5137
  borderTopLeftRadius: theme.roundness,
5138
5138
  borderTopRightRadius: theme.roundness,
5139
5139
  });
5140
- var labelScale = MINIMIZED_LABEL_FONT_SIZE / fontSize;
5140
+ var labelScale = labelScaleValue / fontSize;
5141
5141
  var fontScale = MAXIMIZED_LABEL_FONT_SIZE / fontSize;
5142
5142
  var labelWidth = parentState.labelLayout.width;
5143
5143
  var labelHeight = parentState.labelLayout.height;
@@ -5396,7 +5396,7 @@ var styles$e = StyleSheet.create({
5396
5396
 
5397
5397
  var TextInputDefault = function (_a) {
5398
5398
  var _b, _c;
5399
- var _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.editable, editable = _e === void 0 ? true : _e, label = _a.label, _f = _a.error, error = _f === void 0 ? false : _f, 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, _g = _a.render, render = _g === void 0 ? function (props) { return React$3.createElement(TextInput$1, __assign({}, props)); } : _g, _h = _a.multiline, multiline = _h === void 0 ? false : _h, 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, _j = _a.clearButton, clearButton = _j === void 0 ? false : _j, contentStyle = _a.contentStyle, _k = _a.value, value = _k === void 0 ? "" : _k, 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"]);
5399
+ var _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.editable, editable = _e === void 0 ? true : _e, label = _a.label, _f = _a.error, error = _f === void 0 ? false : _f, 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, _g = _a.render, render = _g === void 0 ? function (props) { return React$3.createElement(TextInput$1, __assign({}, props)); } : _g, _h = _a.multiline, multiline = _h === void 0 ? false : _h, 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, _j = _a.clearButton, clearButton = _j === void 0 ? false : _j, contentStyle = _a.contentStyle, labelStyle = _a.labelStyle, _k = _a.value, value = _k === void 0 ? "" : _k, 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", "labelStyle", "value", "textError", "required"]);
5400
5400
  var colors = theme.colors;
5401
5401
  var font = theme.fonts.bodyLarge;
5402
5402
  var _l = (StyleSheet.flatten(style) || {}), fontSizeStyle = _l.fontSize, fontWeight = _l.fontWeight, lineHeightStyle = _l.lineHeight, height = _l.height, _m = _l.backgroundColor; _m === void 0 ? colors === null || colors === void 0 ? void 0 : colors.backgroundPrimary : _m; var textAlign = _l.textAlign; _l.minHeight; var viewStyle = __rest(_l, ["fontSize", "fontWeight", "lineHeight", "height", "backgroundColor", "textAlign", "minHeight"]);
@@ -5451,6 +5451,9 @@ var TextInputDefault = function (_a) {
5451
5451
  if (disabled) {
5452
5452
  return theme.colors.textSecondary;
5453
5453
  }
5454
+ else if (error) {
5455
+ return theme.colors.textErrorDefault;
5456
+ }
5454
5457
  else if (parentState.focused) {
5455
5458
  return activeColor;
5456
5459
  }
@@ -5469,9 +5472,9 @@ var TextInputDefault = function (_a) {
5469
5472
  }
5470
5473
  else if (((_b = parentState.value) === null || _b === void 0 ? void 0 : _b.toString()) == "") {
5471
5474
  return (React$3.createElement(View, { paddingTop: CONSTANTS.SPACE_12 },
5472
- React$3.createElement(Text$1, { color: getLabelColor(), style: [contentStyle] },
5475
+ React$3.createElement(Text$1, { color: getLabelColor(), style: [labelStyle] },
5473
5476
  label,
5474
- required && (React$3.createElement(Text$1, { style: [contentStyle], color: theme.colors.textErrorDefault },
5477
+ required && (React$3.createElement(Text$1, { style: [labelStyle], color: theme.colors.textErrorDefault },
5475
5478
  " ",
5476
5479
  "*")))));
5477
5480
  }