@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.
package/dist/index.d.ts CHANGED
@@ -676,7 +676,7 @@ declare const TablePagination: React__default.FC<TablePaginationProps>;
676
676
  type TextFieldType = 'text' | 'email' | 'password' | 'number' | 'tel' | 'url';
677
677
  interface TextFieldProps extends Omit<React__default.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'value' | 'type'> {
678
678
  /** Controlled value */
679
- value?: string;
679
+ value?: string | number;
680
680
  /** Change handler - receives string value */
681
681
  onChange?: (value: string) => void;
682
682
  /** Label text */
package/dist/index.esm.js CHANGED
@@ -676,14 +676,16 @@ const validateInput = ({ value, maxLength, errorMessage, required }) => {
676
676
  };
677
677
 
678
678
  const TextField = 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) => {
679
- const [inputValue, setInputValue] = useState(value);
679
+ const normalizeValue = (val) => {
680
+ return val === undefined || val === null ? '' : String(val);
681
+ };
682
+ const [inputValue, setInputValue] = useState(normalizeValue(value));
680
683
  const [inputError, setInputError] = useState('');
681
684
  const [isFocused, setIsFocused] = useState(false);
682
685
  const generatedId = useId();
683
686
  const componentId = id || generatedId;
684
- // ✅ Sincronizar estado interno com prop value externa
685
687
  useEffect(() => {
686
- setInputValue(value);
688
+ setInputValue(normalizeValue(value));
687
689
  }, [value]);
688
690
  const handleChange = useCallback((e) => {
689
691
  const newValue = e.target.value;