@giro-ds/react 3.0.0 → 3.0.1

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.cjs CHANGED
@@ -683,6 +683,10 @@ const TextField$1 = React.forwardRef(({ className, value = '', label, placeholde
683
683
  const [isFocused, setIsFocused] = React.useState(false);
684
684
  const generatedId = React.useId();
685
685
  const componentId = id || generatedId;
686
+ // ✅ Sincronizar estado interno com prop value externa
687
+ React.useEffect(() => {
688
+ setInputValue(value);
689
+ }, [value]);
686
690
  const handleChange = React.useCallback((e) => {
687
691
  const newValue = e.target.value;
688
692
  if (!disabled && (!maxLength || newValue.length <= maxLength)) {
@@ -826,11 +830,13 @@ function parseDate(dateString, locale = 'pt-br') {
826
830
  return date;
827
831
  }
828
832
 
829
- var styles$e = {"zds-date-picker":"DatePicker-module__zds-date-picker___FjFTb","zds-date-picker__calendar-popup":"DatePicker-module__zds-date-picker__calendar-popup___hEkq7","zds-calendar--left":"DatePicker-module__zds-calendar--left___5z2UM","zds-calendar--right":"DatePicker-module__zds-calendar--right___NCJtd"};
833
+ var styles$e = {"zds-date-picker":"DatePicker-module__zds-date-picker___FjFTb","zds-date-picker__calendar-popup":"DatePicker-module__zds-date-picker__calendar-popup___hEkq7","zds-calendar--left":"DatePicker-module__zds-calendar--left___5z2UM","zds-calendar--right":"DatePicker-module__zds-calendar--right___NCJtd","zds-date-picker__icon":"DatePicker-module__zds-date-picker__icon___nYEnv","zds-date-picker__icon--disabled":"DatePicker-module__zds-date-picker__icon--disabled___p4Rr2"};
830
834
 
831
835
  const DatePicker = ({ locale = 'pt-br', calendarPosition = 'left', helperText = '', required = false, label = 'Data', value, defaultValue, onChange, disabled = false, error: externalError, minDate, maxDate, className = '', 'data-testid': testId, }) => {
832
836
  // ✅ IDs únicos para acessibilidade
833
837
  const fieldId = React.useId();
838
+ const calendarId = `${fieldId}-calendar`;
839
+ const errorId = `${fieldId}-error`;
834
840
  const helperTextId = `${fieldId}-help`;
835
841
  // ✅ Suporte controlled/uncontrolled adequado
836
842
  const isControlled = value !== undefined;
@@ -1008,9 +1014,12 @@ const DatePicker = ({ locale = 'pt-br', calendarPosition = 'left', helperText =
1008
1014
  setTempInputValue(formatDate(currentSelectedDate, locale));
1009
1015
  }
1010
1016
  }, [locale, currentSelectedDate, isEditing]);
1011
- return (jsxRuntime.jsx("div", { ref: wrapperRef, children: jsxRuntime.jsxs("div", { className: clsx(styles$e['zds-date-picker']), children: [jsxRuntime.jsx("div", { onClick: handleFieldClick, onFocus: handleFieldFocus, onKeyDown: handleKeyDown, style: { cursor: 'pointer' }, children: jsxRuntime.jsx(TextField, { type: "tel", icon: jsxRuntime.jsx(reactIcons.Calendar16Regular, { onClick: handleIconClick, style: { cursor: 'pointer' } }), onChange: (e) => {
1012
- handleTextFieldChange(String(e));
1013
- }, "aria-label": "Open calendar", "aria-expanded": showCalendar, "aria-controls": "calendar-popup", placeholder: locale === 'en-us' ? 'MM/DD/YYYY' : 'DD/MM/YYYY', value: displayValue, errorMessage: undefined, "aria-invalid": !!currentError, "aria-describedby": combinedHelperText ? helperTextId : undefined, maxLength: 10, helperText: combinedHelperText, required: required, label: label }) }), jsxRuntime.jsx("div", { className: clsx(styles$e['zds-date-picker__calendar-popup'], calendarPosition === 'left' && styles$e['zds-calendar--left'], calendarPosition === 'right' && styles$e['zds-calendar--right']), children: showCalendar && (jsxRuntime.jsx(MemoizedCalendar, { selectedDate: currentSelectedDate, currentDate: currentDate, onDateChange: setCurrentDate, onDaySelect: handleDaySelect, locale: locale, format: locale === 'en-us' ? 'mm/dd/yyyy' : 'dd/mm/yyyy' })) })] }) }));
1017
+ return (jsxRuntime.jsx("div", { ref: wrapperRef, children: jsxRuntime.jsxs("div", { className: clsx(styles$e['zds-date-picker']), children: [jsxRuntime.jsx(TextField, { type: "tel", icon: jsxRuntime.jsx(reactIcons.Calendar16Regular, { onClick: !disabled ? handleIconClick : undefined, className: clsx(styles$e['zds-date-picker__icon'], disabled && styles$e['zds-date-picker__icon--disabled']) }), onChange: (e) => {
1018
+ handleTextFieldChange(String(e));
1019
+ }, onClick: !disabled ? handleFieldClick : undefined, onFocus: !disabled ? handleFieldFocus : undefined, onKeyDown: handleKeyDown, value: displayValue, helperText: combinedHelperText, maxLength: 10, required: required, label: label, disabled: disabled, id: fieldId, className: className, "data-testid": testId, placeholder: locale === 'en-us' ? 'MM/DD/YYYY' : 'DD/MM/YYYY', "aria-label": "Open calendar", "aria-expanded": showCalendar, "aria-controls": calendarId, "aria-invalid": !!currentError, "aria-describedby": currentError ? errorId : (helperText ? helperTextId : undefined) }), jsxRuntime.jsx("div", { className: clsx(styles$e['zds-date-picker__calendar-popup'], calendarPosition === 'left' && styles$e['zds-calendar--left'], calendarPosition === 'right' && styles$e['zds-calendar--right']), children: showCalendar && (jsxRuntime.jsx(MemoizedCalendar, { selectedDate: currentSelectedDate, currentDate: currentDate, onDateChange: setCurrentDate, onDaySelect: handleDaySelect, locale: locale, format: locale === 'en-us' ? 'mm/dd/yyyy' : 'dd/mm/yyyy', minDate: minDate, maxDate: maxDate, id: calendarId, onClear: () => {
1020
+ handleDateChange(null);
1021
+ setCurrentDate(new Date());
1022
+ } })) })] }) }));
1014
1023
  };
1015
1024
  var DatePicker_default = React.memo(DatePicker);
1016
1025