@giro-ds/react 3.0.1 → 3.0.2

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.
@@ -3,7 +3,7 @@ export type TextFieldType = 'text' | 'email' | 'password' | 'number' | 'tel' | '
3
3
  export type TooltipPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
4
4
  export interface TextFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'value' | 'type'> {
5
5
  /** Controlled value */
6
- value?: string;
6
+ value?: string | number;
7
7
  /** Change handler - receives string value */
8
8
  onChange?: (value: string) => void;
9
9
  /** Label text */
package/dist/index.cjs CHANGED
@@ -678,14 +678,16 @@ const validateInput = ({ value, maxLength, errorMessage, required }) => {
678
678
  };
679
679
 
680
680
  const TextField$1 = React.forwardRef(({ className, value = '', label, placeholder, type = 'text', onChange, disabled = false, maxLength = 30, required = false, helperText, tooltip = false, tooltipText = '', side = 'bottom', align = 'start', errorMessage = '', id, icon, onBlur, onFocus, name, ...inputProps }, ref) => {
681
- const [inputValue, setInputValue] = React.useState(value);
681
+ const normalizeValue = (val) => {
682
+ return val === undefined || val === null ? '' : String(val);
683
+ };
684
+ const [inputValue, setInputValue] = React.useState(normalizeValue(value));
682
685
  const [inputError, setInputError] = React.useState('');
683
686
  const [isFocused, setIsFocused] = React.useState(false);
684
687
  const generatedId = React.useId();
685
688
  const componentId = id || generatedId;
686
- // ✅ Sincronizar estado interno com prop value externa
687
689
  React.useEffect(() => {
688
- setInputValue(value);
690
+ setInputValue(normalizeValue(value));
689
691
  }, [value]);
690
692
  const handleChange = React.useCallback((e) => {
691
693
  const newValue = e.target.value;