@useblu/ocean-react 1.139.0 → 1.139.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/index.js CHANGED
@@ -34908,7 +34908,9 @@ var DatePickerSingle = e.forwardRef(function (_a, ref) {
34908
34908
  'date-field-focussed': currentField === 'start-date',
34909
34909
  }), name: "start-date", value: value, onChange: (editable && inputChange) || undefined, placeholder: inputPlaceholder, adornment: e.createElement(On, { size: 20, stroke: "#B6B9CC" }), autoComplete: "off", readOnly: !editable, disabled: disabled, error: !disabled && error, inputMode: "numeric", helperText: (!disabled && !showDayPicker && helperText) || undefined, maxLength: 10 }))),
34910
34910
  inline && label && (e.createElement("div", { className: "ods-date__inline-label" }, label)),
34911
- !disabled && calendarOpen && (e.createElement("div", { "data-testid": "datepicker-calendar", className: "ods-date__calendar-container", role: "presentation", onClick: handleCalendarClick },
34911
+ !disabled && calendarOpen && (e.createElement("div", { "data-testid": "datepicker-calendar", className: classNames('ods-date__calendar-container', {
34912
+ 'ods-date__calendar-container--inline': inline,
34913
+ }), role: "presentation", onClick: handleCalendarClick },
34912
34914
  e.createElement(DayPicker, { mode: "single", locale: localeOption, weekStartsOn: 0, classNames: CustomStyles(inline), className: className, onDayClick: handleDayClickWithModifiers, formatters: { formatDay: formatDay }, selected: selectedDay, disabled: startsToday ? { before: new Date() } : disabledDays, defaultMonth: currentMonthToDisplay, components: {
34913
34915
  Caption: CaptionWithTooltip,
34914
34916
  } }),
@@ -34917,7 +34919,7 @@ var DatePickerSingle = e.forwardRef(function (_a, ref) {
34917
34919
  DatePickerSingle.displayName = 'DatePickerSingle';
34918
34920
 
34919
34921
  function useDatePicker(_a) {
34920
- var values = _a.values, onSelect = _a.onSelect, startsToday = _a.startsToday, locale = _a.locale, disabledDaysMessage = _a.disabledDaysMessage;
34922
+ var values = _a.values, onSelect = _a.onSelect, startsToday = _a.startsToday, locale = _a.locale, disabledDaysMessage = _a.disabledDaysMessage, error = _a.error;
34921
34923
  var localeOption = locale || ptBr;
34922
34924
  var localeDateFormat = localeOption &&
34923
34925
  localeOption.formatLong &&
@@ -35027,6 +35029,13 @@ function useDatePicker(_a) {
35027
35029
  }
35028
35030
  }
35029
35031
  };
35032
+ var hasError = typeof error === 'object' ? !!(error.from || error.to) : !!error;
35033
+ e.useEffect(function () {
35034
+ if (hasError) {
35035
+ setShowDayPicker(false);
35036
+ setCurrentField('');
35037
+ }
35038
+ }, [hasError]);
35030
35039
  var handleCloseByOutside = function () {
35031
35040
  if (showDayPicker) {
35032
35041
  setShowDayPicker(false);
@@ -35102,7 +35111,17 @@ var DatePickerRange = e.forwardRef(function (_a, ref) {
35102
35111
  startsToday: startsToday,
35103
35112
  locale: locale,
35104
35113
  disabledDaysMessage: disabledDaysMessage,
35114
+ error: error,
35105
35115
  }), input1Ref = _b.input1Ref, input2Ref = _b.input2Ref, showDayPicker = _b.showDayPicker, selectedDays = _b.selectedDays, CustomStyles = _b.CustomStyles, localeOption = _b.localeOption, currentField = _b.currentField, inputPlaceholder = _b.inputPlaceholder, handleDayMouseEnter = _b.handleDayMouseEnter, handleDayClickWithModifiers = _b.handleDayClickWithModifiers, showDisabledTooltip = _b.showDisabledTooltip, tooltipMessage = _b.tooltipMessage, tooltipPosition = _b.tooltipPosition, handleCalendarClick = _b.handleCalendarClick, handleDisplayMonth = _b.handleDisplayMonth, inputChange = _b.inputChange, createHandleToggleClick = _b.createHandleToggleClick, formatDay = _b.formatDay, handleCloseByOutside = _b.handleCloseByOutside, currentMonthToDisplay = _b.currentMonthToDisplay;
35116
+ var fieldError = function (field) {
35117
+ return !disabled && (typeof error === 'object' ? !!error[field] : !!error);
35118
+ };
35119
+ var fieldHelperText = function (field) {
35120
+ if (disabled || showDayPicker)
35121
+ return undefined;
35122
+ var text = typeof helperText === 'object' ? helperText[field] : helperText;
35123
+ return text || undefined;
35124
+ };
35106
35125
  return (e.createElement("div", null,
35107
35126
  showDayPicker && (e.createElement("div", { className: "ods-date-background", "data-testid": "date-picker-outside", onClick: handleCloseByOutside })),
35108
35127
  e.createElement("div", __assign$1({ className: classNames('ods-date', className), ref: ref }, rest),
@@ -35111,12 +35130,12 @@ var DatePickerRange = e.forwardRef(function (_a, ref) {
35111
35130
  labels && labels.from && (e.createElement("label", { htmlFor: "start-date" }, labels.from)),
35112
35131
  e.createElement(Input, { ref: input1Ref, "data-testid": "datepicker-input-1", id: "start-date", type: "text", className: classNames({
35113
35132
  'date-field-focussed': currentField === 'start-date',
35114
- }), name: "start-date", value: values.from, onChange: (editable && inputChange) || undefined, placeholder: inputPlaceholder, adornment: e.createElement(On, { size: 20, stroke: "#B6B9CC" }), autoComplete: "off", readOnly: !editable, disabled: disabled, error: !disabled && error, inputMode: "numeric", helperText: (!disabled && !showDayPicker && helperText) || undefined, maxLength: 10 })),
35133
+ }), name: "start-date", value: values.from, onChange: (editable && inputChange) || undefined, placeholder: inputPlaceholder, adornment: e.createElement(On, { size: 20, stroke: "#B6B9CC" }), autoComplete: "off", readOnly: !editable, disabled: disabled, error: fieldError('from'), inputMode: "numeric", helperText: fieldHelperText('from'), maxLength: 10 })),
35115
35134
  e.createElement("div", { className: "ods-date__form-controls", "data-testid": "date-picker-second-field-wrapper", onClick: function () { return createHandleToggleClick('end-date'); } },
35116
35135
  labels && labels.to && (e.createElement("label", { htmlFor: "end-date" }, labels.to)),
35117
35136
  e.createElement(Input, { ref: input2Ref, "data-testid": "datepicker-input-2", id: "end-date", type: "text", className: classNames({
35118
35137
  'date-field-focussed': currentField === 'end-date',
35119
- }), name: "end-date", value: values.to, onChange: (editable && inputChange) || undefined, placeholder: inputPlaceholder, adornment: e.createElement(On, { size: 20, stroke: "#B6B9CC" }), autoComplete: "off", readOnly: !editable, disabled: disabled, error: !disabled && error, inputMode: "numeric", helperText: (!disabled && !showDayPicker && helperText) || undefined, maxLength: 10 })),
35138
+ }), name: "end-date", value: values.to, onChange: (editable && inputChange) || undefined, placeholder: inputPlaceholder, adornment: e.createElement(On, { size: 20, stroke: "#B6B9CC" }), autoComplete: "off", readOnly: !editable, disabled: disabled, error: fieldError('to'), inputMode: "numeric", helperText: fieldHelperText('to'), maxLength: 10 })),
35120
35139
  !disabled && showDayPicker && (e.createElement("div", { "data-testid": "datepicker-calendar", className: "ods-date__calendar-container", role: "presentation", onClick: handleCalendarClick },
35121
35140
  e.createElement(DayPicker, { mode: "range", locale: localeOption, weekStartsOn: 0, classNames: CustomStyles, className: className, onDayClick: handleDayClickWithModifiers, onDayMouseEnter: function (day) { return handleDayMouseEnter(day); }, formatters: { formatDay: formatDay }, selected: selectedDays, disabled: startsToday ? { before: new Date() } : disabledDays, defaultMonth: currentMonthToDisplay, components: {
35122
35141
  Caption: function (_a) {