sapo-components-ui-rn 1.0.36 → 1.0.38

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.
@@ -14,5 +14,5 @@ interface SearchInputProps {
14
14
  onChangeText?: (text: string) => void;
15
15
  height?: number;
16
16
  }
17
- declare const SearchInput: ({ value, disabled, rightIcon, clearButton, placeholder, onFocus, onBlur, onChangeText, style, height, }: SearchInputProps) => React.JSX.Element;
17
+ declare const SearchInput: ({ value, disabled, rightIcon, clearButton, placeholder, onFocus, onBlur, onChangeText, style, height, textStyle, }: SearchInputProps) => React.JSX.Element;
18
18
  export default SearchInput;
@@ -19,6 +19,7 @@ export interface SelectionFieldProps extends TouchableOpacityProps {
19
19
  disabled?: boolean;
20
20
  onPress?: (res?: any) => void;
21
21
  theme?: ThemeProp;
22
+ required?: boolean;
22
23
  }
23
- declare const _default: React.MemoExoticComponent<({ style, content, label, error, borderColor, left, right, textStyle, labelStyle, textProps, onPress, disabled, textColor, labelColor, size, theme: themeOverrides, ...props }: SelectionFieldProps) => React.JSX.Element>;
24
+ declare const _default: React.MemoExoticComponent<({ style, content, label, error, borderColor, left, right, textStyle, labelStyle, textProps, onPress, disabled, textColor, labelColor, size, theme: themeOverrides, required, ...props }: SelectionFieldProps) => React.JSX.Element>;
24
25
  export default _default;
@@ -143,6 +143,7 @@ export type Props = React.ComponentPropsWithRef<typeof NativeTextInput> & {
143
143
  underlineStyle?: StyleProp<ViewStyle>;
144
144
  minHeight?: number;
145
145
  clearButton?: boolean;
146
+ textStyle?: StyleProp<TextStyle>;
146
147
  };
147
148
  interface CompoundedComponent extends React.ForwardRefExoticComponent<Props & React.RefAttributes<TextInputHandles>> {
148
149
  Affix: React.FunctionComponent<Partial<TextInputAffixProps>>;
package/dist/index.esm.js CHANGED
@@ -5703,7 +5703,7 @@ var DefaultRenderer = function (props) { return React__default.createElement(Tex
5703
5703
  * @extends TextInput props https://reactnative.dev/docs/textinput#props
5704
5704
  */
5705
5705
  var TextInput = forwardRef(function (_a, ref) {
5706
- var _b = _a.mode, mode = _b === void 0 ? "flat" : _b, _c = _a.dense, dense = _c === void 0 ? false : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.error, errorProp = _e === void 0 ? false : _e, _f = _a.multiline, multiline = _f === void 0 ? false : _f, _g = _a.editable, editable = _g === void 0 ? true : _g, contentStyle = _a.contentStyle, _h = _a.render, render = _h === void 0 ? DefaultRenderer : _h; _a.theme; var placeholderTextColor = _a.placeholderTextColor, clearButton = _a.clearButton, rest = __rest(_a, ["mode", "dense", "disabled", "error", "multiline", "editable", "contentStyle", "render", "theme", "placeholderTextColor", "clearButton"]);
5706
+ var _b = _a.mode, mode = _b === void 0 ? "flat" : _b, _c = _a.dense, dense = _c === void 0 ? false : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.error, errorProp = _e === void 0 ? false : _e, _f = _a.multiline, multiline = _f === void 0 ? false : _f, _g = _a.editable, editable = _g === void 0 ? true : _g, contentStyle = _a.contentStyle, _h = _a.render, render = _h === void 0 ? DefaultRenderer : _h; _a.theme; var placeholderTextColor = _a.placeholderTextColor, clearButton = _a.clearButton, textStyle = _a.textStyle, rest = __rest(_a, ["mode", "dense", "disabled", "error", "multiline", "editable", "contentStyle", "render", "theme", "placeholderTextColor", "clearButton", "textStyle"]);
5707
5707
  var theme = useInternalTheme();
5708
5708
  var isControlled = rest.value !== undefined;
5709
5709
  var validInputValue = isControlled ? rest.value : rest.defaultValue;
@@ -5902,7 +5902,7 @@ var TextInput = forwardRef(function (_a, ref) {
5902
5902
  inputContainerLayout: inputContainerLayout,
5903
5903
  }, innerRef: function (ref) {
5904
5904
  root.current = ref;
5905
- }, onFocus: handleFocus, forceFocus: forceFocus, onBlur: handleBlur, allowFontScaling: false, onChangeText: handleChangeText, onLayoutAnimatedText: handleLayoutAnimatedText, onInputLayout: handleInputContainerLayout, onLabelTextLayout: handleLabelTextLayout, onLeftAffixLayoutChange: onLeftAffixLayoutChange, onRightAffixLayoutChange: onRightAffixLayoutChange, maxFontSizeMultiplier: maxFontSizeMultiplier, contentStyle: contentStyle, scaledLabel: scaledLabel })));
5905
+ }, onFocus: handleFocus, forceFocus: forceFocus, onBlur: handleBlur, allowFontScaling: false, onChangeText: handleChangeText, onLayoutAnimatedText: handleLayoutAnimatedText, onInputLayout: handleInputContainerLayout, onLabelTextLayout: handleLabelTextLayout, onLeftAffixLayoutChange: onLeftAffixLayoutChange, onRightAffixLayoutChange: onRightAffixLayoutChange, maxFontSizeMultiplier: maxFontSizeMultiplier, contentStyle: [contentStyle, textStyle], scaledLabel: scaledLabel })));
5906
5906
  }
5907
5907
  return (React__default.createElement(TextInputFlat, __assign({ dense: dense, disabled: disabled, error: errorProp, editable: editable, clearButton: clearButton, render: render }, rest, { theme: theme, value: value, parentState: {
5908
5908
  labeled: labeled,
@@ -6742,12 +6742,22 @@ var styles$2 = StyleSheet.create({
6742
6742
  });
6743
6743
 
6744
6744
  var SelectionField = function (_a) {
6745
- var style = _a.style, _b = _a.content, content = _b === void 0 ? "" : _b, _c = _a.label, label = _c === void 0 ? "" : _c, _d = _a.error, error = _d === void 0 ? "" : _d, borderColor = _a.borderColor; _a.left; var right = _a.right, textStyle = _a.textStyle; _a.labelStyle; var textProps = _a.textProps, onPress = _a.onPress, _e = _a.disabled, disabled = _e === void 0 ? false : _e, textColor = _a.textColor, labelColor = _a.labelColor, _f = _a.size, size = _f === void 0 ? 14 : _f; _a.theme; var props = __rest(_a, ["style", "content", "label", "error", "borderColor", "left", "right", "textStyle", "labelStyle", "textProps", "onPress", "disabled", "textColor", "labelColor", "size", "theme"]);
6745
+ var style = _a.style, _b = _a.content, content = _b === void 0 ? "" : _b, _c = _a.label, label = _c === void 0 ? "" : _c, _d = _a.error, error = _d === void 0 ? "" : _d, borderColor = _a.borderColor; _a.left; var right = _a.right, textStyle = _a.textStyle; _a.labelStyle; var textProps = _a.textProps, onPress = _a.onPress, _e = _a.disabled, disabled = _e === void 0 ? false : _e, textColor = _a.textColor, labelColor = _a.labelColor, _f = _a.size, size = _f === void 0 ? 16 : _f; _a.theme; var _g = _a.required, required = _g === void 0 ? false : _g, props = __rest(_a, ["style", "content", "label", "error", "borderColor", "left", "right", "textStyle", "labelStyle", "textProps", "onPress", "disabled", "textColor", "labelColor", "size", "theme", "required"]);
6746
6746
  var theme = useInternalTheme();
6747
6747
  var colors = theme.colors;
6748
6748
  var disabledTextStyle = {
6749
6749
  color: colors.textSecondary,
6750
6750
  };
6751
+ var getColor = function () {
6752
+ if (disabled)
6753
+ return colors.textPlaceholder;
6754
+ if (error.length > 0)
6755
+ return colors.textErrorDefault;
6756
+ if (content.toString() === "") {
6757
+ return textColor || colors.textSecondary;
6758
+ }
6759
+ return textColor || colors.textDefault;
6760
+ };
6751
6761
  return (React__default.createElement(View, null,
6752
6762
  React__default.createElement(ScaleButton$1, __assign({ activeOpacity: 0.8, onPress: onPress }, props, { disabled: disabled || false }),
6753
6763
  React__default.createElement(View, { style: [
@@ -6774,15 +6784,20 @@ var SelectionField = function (_a) {
6774
6784
  ] },
6775
6785
  React__default.createElement(Spacer, { width: SPACE_12 }),
6776
6786
  React__default.createElement(View, { full: true },
6777
- content.toString() !== "" && label.toString() !== "" && (React__default.createElement(Text$1, { size: 12, color: labelColor || colors.textSecondary, style: [
6787
+ content.toString() !== "" && label.toString() !== "" && (React__default.createElement(Text$1, { color: labelColor || colors.textSecondary, style: [
6788
+ styles$1.text12,
6778
6789
  disabled && {
6779
6790
  color: colors.textPlaceholder,
6780
6791
  },
6781
6792
  error.length > 0 && {
6782
6793
  color: colors.textErrorDefault,
6783
6794
  },
6784
- ] }, label)),
6785
- React__default.createElement(Text$1, __assign({ numberOfLines: 1, color: textColor || colors.textDefault, size: size, style: [disabled && disabledTextStyle, textStyle] }, textProps), content.toString() === "" ? label : content)),
6795
+ ] },
6796
+ label,
6797
+ required && React__default.createElement(Text$1, { color: colors.textErrorDefault }, " *"))),
6798
+ React__default.createElement(Text$1, __assign({ numberOfLines: 1, color: getColor(), size: size, style: [disabled && disabledTextStyle, textStyle] }, textProps),
6799
+ content.toString() === "" ? label : content,
6800
+ required && content.toString() === "" && (React__default.createElement(Text$1, { color: colors.textErrorDefault }, " *")))),
6786
6801
  right || React__default.createElement(Icon$1, { name: "IconArrowDown", type: "Svg", size: 24 }),
6787
6802
  React__default.createElement(Spacer, { width: SPACE_12 }))),
6788
6803
  error.length > 0 && (React__default.createElement(View, { paddingHorizontal: SPACE_12, paddingVertical: SPACE_4 },
@@ -6802,11 +6817,11 @@ var styles$1 = StyleSheet.create(__assign(__assign({}, containerStyles), { disab
6802
6817
  var index = React__default.memo(SelectionField);
6803
6818
 
6804
6819
  var SearchInput = function (_a) {
6805
- 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;
6820
+ 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, textStyle = _a.textStyle;
6806
6821
  var theme = useInternalTheme();
6807
6822
  var colors = theme.colors;
6808
6823
  return (React__default.createElement(TextInput, { left: React__default.createElement(View, { center: true },
6809
- React__default.createElement(Icon$1, { name: "IconSearch", type: "Svg", size: 18 })), disabled: disabled, value: value, clearButton: clearButton, mode: "default", label: placeholder, placeholder: placeholder, right: rightIcon, onFocus: onFocus, onBlur: onBlur, allowFontScaling: false, onChangeText: onChangeText, style: [
6824
+ React__default.createElement(Icon$1, { name: "IconSearch", type: "Svg", size: 18 })), disabled: disabled, value: value, clearButton: clearButton, mode: "default", label: placeholder, placeholder: placeholder, right: rightIcon, onFocus: onFocus, onBlur: onBlur, allowFontScaling: false, onChangeText: onChangeText, textStyle: textStyle, style: [
6810
6825
  {
6811
6826
  height: height || 40,
6812
6827
  },
@@ -6818,7 +6833,6 @@ var SearchInput = function (_a) {
6818
6833
  style,
6819
6834
  ] }));
6820
6835
  };
6821
- StyleSheet.create(__assign({}, containerStyles));
6822
6836
 
6823
6837
  var Tag = function (_a) {
6824
6838
  var style = _a.style, _b = _a.borderRadius, borderRadius = _b === void 0 ? CONSTANTS.BORDER_RADIUS_ROUNDED : _b, _c = _a.title, title = _c === void 0 ? "content" : _c, textStyle = _a.textStyle, onPress = _a.onPress, _d = _a.disabled, disabled = _d === void 0 ? false : _d, leftIcon = _a.leftIcon, rightIcon = _a.rightIcon, _e = _a.isActive, isActive = _e === void 0 ? false : _e, _f = _a.ellipsizeMode, ellipsizeMode = _f === void 0 ? "tail" : _f, _g = _a.numberOfLines, numberOfLines = _g === void 0 ? 1 : _g, _h = _a.hideRightIcon, hideRightIcon = _h === void 0 ? false : _h, _j = _a.height, height = _j === void 0 ? 32 : _j;
@@ -6852,7 +6866,7 @@ var Tag = function (_a) {
6852
6866
  textStyle,
6853
6867
  ] }, title)),
6854
6868
  rightIcon ? (React__default.createElement(View, { paddingLeft: CONSTANTS.SPACE_4 }, rightIcon)) : hideRightIcon ? (React__default.createElement(View, null)) : (React__default.createElement(View, { paddingLeft: CONSTANTS.SPACE_4 },
6855
- React__default.createElement(SvgIcon, { name: "IconClose" }))))));
6869
+ React__default.createElement(Icon$1, { name: "IconClose", type: "Svg", size: 24, color: colors.iconBrandDefault }))))));
6856
6870
  };
6857
6871
  var styles = StyleSheet.create(__assign({}, containerStyles));
6858
6872