@sustaina/shared-ui 1.70.6 → 1.70.7

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.mjs CHANGED
@@ -5656,12 +5656,9 @@ function MonthCal({
5656
5656
  );
5657
5657
  const min = React.useMemo(() => normalizeMonth(minDate), [minDate]);
5658
5658
  const max = React.useMemo(() => normalizeMonth(maxDate), [maxDate]);
5659
- let effectiveMin = min;
5660
- if (min && max && min > max) {
5661
- effectiveMin = max;
5662
- }
5663
- const minYear = effectiveMin?.getFullYear();
5664
- const minMonth = effectiveMin?.getMonth();
5659
+ const hasConflictingBounds = Boolean(min && max && min > max);
5660
+ const minYear = min?.getFullYear();
5661
+ const minMonth = min?.getMonth();
5665
5662
  const maxYear = max?.getFullYear();
5666
5663
  const maxMonth = max?.getMonth();
5667
5664
  const selectedMonthYear = selectedMonthDate?.getFullYear();
@@ -5674,6 +5671,7 @@ function MonthCal({
5674
5671
  }
5675
5672
  }, [selectedMonthYear]);
5676
5673
  React.useEffect(() => {
5674
+ if (hasConflictingBounds) return;
5677
5675
  if (typeof minYear === "number" && menuYear < minYear) {
5678
5676
  setMenuYear(minYear);
5679
5677
  return;
@@ -5681,10 +5679,11 @@ function MonthCal({
5681
5679
  if (typeof maxYear === "number" && menuYear > maxYear) {
5682
5680
  setMenuYear(maxYear);
5683
5681
  }
5684
- }, [minYear, maxYear, menuYear]);
5685
- const disablePrevYear = typeof minYear === "number" ? menuYear <= minYear : false;
5686
- const disableNextYear = typeof maxYear === "number" ? menuYear >= maxYear : false;
5682
+ }, [hasConflictingBounds, minYear, maxYear, menuYear]);
5683
+ const disablePrevYear = hasConflictingBounds || (typeof minYear === "number" ? menuYear <= minYear : false);
5684
+ const disableNextYear = hasConflictingBounds || (typeof maxYear === "number" ? menuYear >= maxYear : false);
5687
5685
  const yearOptions = React.useMemo(() => {
5686
+ if (hasConflictingBounds) return [menuYear];
5688
5687
  const fallbackWindow = 50;
5689
5688
  const start = typeof minYear === "number" ? minYear : menuYear - fallbackWindow;
5690
5689
  const end = typeof maxYear === "number" ? maxYear : menuYear + fallbackWindow;
@@ -5697,7 +5696,7 @@ function MonthCal({
5697
5696
  years.sort((a, b) => a - b);
5698
5697
  }
5699
5698
  return years;
5700
- }, [maxYear, menuYear, minYear]);
5699
+ }, [hasConflictingBounds, maxYear, menuYear, minYear]);
5701
5700
  const formatYearLabel = React.useCallback(
5702
5701
  (year) => {
5703
5702
  const raw = callbacks?.yearLabel?.(year);
@@ -5708,13 +5707,14 @@ function MonthCal({
5708
5707
  );
5709
5708
  const handleYearSelect = React.useCallback(
5710
5709
  (nextValue) => {
5710
+ if (hasConflictingBounds) return;
5711
5711
  const nextYear = Number.parseInt(nextValue, 10);
5712
5712
  if (Number.isNaN(nextYear)) return;
5713
5713
  if (typeof minYear === "number" && nextYear < minYear) return;
5714
5714
  if (typeof maxYear === "number" && nextYear > maxYear) return;
5715
5715
  setMenuYear(nextYear);
5716
5716
  },
5717
- [maxYear, minYear]
5717
+ [hasConflictingBounds, maxYear, minYear]
5718
5718
  );
5719
5719
  const disabledPairs = React.useMemo(() => {
5720
5720
  if (!disabledDates?.length) return [];
@@ -5799,7 +5799,7 @@ function MonthCal({
5799
5799
  const disabledByList = disabledPairs.some(
5800
5800
  (d) => d.year === menuYear && d.month === m.number
5801
5801
  );
5802
- const isDisabled = afterMax || beforeMin || disabledByList;
5802
+ const isDisabled = hasConflictingBounds || afterMax || beforeMin || disabledByList;
5803
5803
  const cellDate = new Date(menuYear, m.number, 1);
5804
5804
  cellDate.setHours(0, 0, 0, 0);
5805
5805
  const isSelected = !isDisabled && !!selectedMonthDate && selectedMonthDate.getFullYear() === menuYear && selectedMonthDate.getMonth() === m.number;
@@ -8677,7 +8677,7 @@ var AdvanceSearch = ({
8677
8677
  } = useAdvanceSearch({ fields: fieldsData, limitRows });
8678
8678
  const form = useForm({
8679
8679
  mode: "onSubmit",
8680
- reValidateMode: "onSubmit",
8680
+ reValidateMode: "onChange",
8681
8681
  defaultValues: {}
8682
8682
  });
8683
8683
  const { handleSubmit, unregister, resetField, getValues, clearErrors, setError } = form;