@ostack.tech/ui 0.11.1 → 0.11.3
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/ostack-ui.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { forwardRef, createContext, useContext, useCallback, useRef, useEffect, useId, useMemo, useState, memo, Fragment as Fragment$1, isValidElement, cloneElement, Children, useImperativeHandle, startTransition, useLayoutEffect as useLayoutEffect$2, useSyncExternalStore, useDeferredValue } from "react";
|
|
3
3
|
import { parseKeybinding, tinykeys } from "tinykeys";
|
|
4
4
|
import fromExponential from "from-exponential";
|
|
5
|
-
import { isValid, isDate, addMonths,
|
|
5
|
+
import { isValid, isDate, addMonths, isBefore, startOfMonth, isAfter, setMonth, setYear, startOfYear, format, max, min, endOfMonth, isWithinInterval, lastDayOfMonth, isSameDay, isEqual, parseISO, parse } from "date-fns";
|
|
6
6
|
import { createStore, useStore as useStore$1, create } from "zustand";
|
|
7
7
|
import { shallow } from "zustand/shallow";
|
|
8
8
|
import { numericFormatter, removeNumericFormat, NumericFormat } from "react-number-format";
|
|
@@ -8761,12 +8761,12 @@ const CalendarHeader = memo(function CalendarHeader2({
|
|
|
8761
8761
|
months[0].date,
|
|
8762
8762
|
pagedNavigation ? -months.length : -1
|
|
8763
8763
|
);
|
|
8764
|
-
const allowsPrevMonth = minAllowedDate == null ||
|
|
8764
|
+
const allowsPrevMonth = minAllowedDate == null || !isBefore(prevMonth, startOfMonth(minAllowedDate));
|
|
8765
8765
|
const nextMonth = addMonths(
|
|
8766
8766
|
months[0].date,
|
|
8767
8767
|
pagedNavigation ? months.length : 1
|
|
8768
8768
|
);
|
|
8769
|
-
const allowsNextMonth = maxAllowedDate == null ||
|
|
8769
|
+
const allowsNextMonth = maxAllowedDate == null || !isAfter(nextMonth, startOfMonth(maxAllowedDate));
|
|
8770
8770
|
const handlePrevClick = useCallback(() => {
|
|
8771
8771
|
if (allowsPrevMonth) {
|
|
8772
8772
|
goToMonth(prevMonth);
|
|
@@ -8787,18 +8787,24 @@ const CalendarHeader = memo(function CalendarHeader2({
|
|
|
8787
8787
|
}
|
|
8788
8788
|
return months2;
|
|
8789
8789
|
}, []);
|
|
8790
|
+
const displayYear = displayDate.getFullYear();
|
|
8791
|
+
const curYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
8792
|
+
const nearestCentury = curYear + 50 - (curYear + 50) % 100;
|
|
8793
|
+
const minYear = minAllowedDate ? minAllowedDate.getFullYear() : Math.min(displayYear, nearestCentury - 100);
|
|
8794
|
+
const maxYear = maxAllowedDate ? maxAllowedDate.getFullYear() : Math.max(displayYear, nearestCentury + 99);
|
|
8790
8795
|
const yearDates = useMemo(() => {
|
|
8791
|
-
const displayYear = getYear(displayDate);
|
|
8792
|
-
const curYear = getYear(/* @__PURE__ */ new Date());
|
|
8793
|
-
const nearestCentury = curYear + 50 - (curYear + 50) % 100;
|
|
8794
|
-
const minYear = minAllowedDate ? getYear(minAllowedDate) : Math.min(displayYear, nearestCentury - 100);
|
|
8795
|
-
const maxYear = maxAllowedDate ? getYear(maxAllowedDate) : Math.max(displayYear, nearestCentury + 99);
|
|
8796
8796
|
const years = [];
|
|
8797
|
+
if (displayYear < minYear) {
|
|
8798
|
+
years.push(setYear(startOfYear(/* @__PURE__ */ new Date()), displayYear));
|
|
8799
|
+
}
|
|
8797
8800
|
for (let year = minYear; year <= maxYear; year++) {
|
|
8798
8801
|
years.push(setYear(startOfYear(/* @__PURE__ */ new Date()), year));
|
|
8799
8802
|
}
|
|
8803
|
+
if (displayYear > maxYear) {
|
|
8804
|
+
years.push(setYear(startOfYear(/* @__PURE__ */ new Date()), displayYear));
|
|
8805
|
+
}
|
|
8800
8806
|
return years;
|
|
8801
|
-
}, [
|
|
8807
|
+
}, [displayYear, minYear, maxYear]);
|
|
8802
8808
|
const handleMonthChange = useCallback(
|
|
8803
8809
|
(value) => goToMonth(
|
|
8804
8810
|
addMonths(
|
|
@@ -8867,21 +8873,36 @@ const CalendarHeader = memo(function CalendarHeader2({
|
|
|
8867
8873
|
})
|
|
8868
8874
|
}
|
|
8869
8875
|
);
|
|
8870
|
-
const monthOptions = useMemo(
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8876
|
+
const monthOptions = useMemo(() => {
|
|
8877
|
+
const minMonth = minAllowedDate?.getMonth();
|
|
8878
|
+
const maxMonth = maxAllowedDate?.getMonth();
|
|
8879
|
+
return monthDates.map((monthDate) => {
|
|
8880
|
+
const month = monthDate.getMonth();
|
|
8881
|
+
return /* @__PURE__ */ jsx(
|
|
8882
|
+
Option,
|
|
8883
|
+
{
|
|
8884
|
+
value: month,
|
|
8885
|
+
disabled: minAllowedDate && minAllowedDate.getFullYear() === maxAllowedDate?.getFullYear() && (month < minMonth || month > maxMonth),
|
|
8886
|
+
children: format(monthDate, MONTH_FORMAT, { locale: locale7 })
|
|
8887
|
+
},
|
|
8888
|
+
month
|
|
8889
|
+
);
|
|
8890
|
+
});
|
|
8891
|
+
}, [locale7, maxAllowedDate, minAllowedDate, monthDates]);
|
|
8882
8892
|
const yearOptions = useMemo(
|
|
8883
|
-
() => yearDates.map((yearDate) =>
|
|
8884
|
-
|
|
8893
|
+
() => yearDates.map((yearDate) => {
|
|
8894
|
+
const year = yearDate.getFullYear();
|
|
8895
|
+
return /* @__PURE__ */ jsx(
|
|
8896
|
+
Option,
|
|
8897
|
+
{
|
|
8898
|
+
value: year,
|
|
8899
|
+
disabled: year < minYear || year > maxYear,
|
|
8900
|
+
children: format(yearDate, YEAR_FORMAT, { locale: locale7 })
|
|
8901
|
+
},
|
|
8902
|
+
year
|
|
8903
|
+
);
|
|
8904
|
+
}),
|
|
8905
|
+
[locale7, maxYear, minYear, yearDates]
|
|
8885
8906
|
);
|
|
8886
8907
|
return /* @__PURE__ */ jsxs(
|
|
8887
8908
|
"header",
|
|
@@ -8908,7 +8929,7 @@ const CalendarHeader = memo(function CalendarHeader2({
|
|
|
8908
8929
|
monthSelectProps?.onValueChange,
|
|
8909
8930
|
handleMonthChange
|
|
8910
8931
|
),
|
|
8911
|
-
value: getMonth(
|
|
8932
|
+
value: displayDate.getMonth(),
|
|
8912
8933
|
children: monthOptions
|
|
8913
8934
|
}
|
|
8914
8935
|
),
|
|
@@ -8926,7 +8947,7 @@ const CalendarHeader = memo(function CalendarHeader2({
|
|
|
8926
8947
|
yearSelectProps?.onValueChange,
|
|
8927
8948
|
handleYearChange
|
|
8928
8949
|
),
|
|
8929
|
-
value:
|
|
8950
|
+
value: displayDate.getFullYear(),
|
|
8930
8951
|
children: yearOptions
|
|
8931
8952
|
}
|
|
8932
8953
|
)
|
|
@@ -8981,6 +9002,7 @@ function Calendar({
|
|
|
8981
9002
|
disableNavigation,
|
|
8982
9003
|
disabled,
|
|
8983
9004
|
modifiers,
|
|
9005
|
+
apiRef,
|
|
8984
9006
|
headerProps,
|
|
8985
9007
|
headerLabelProps,
|
|
8986
9008
|
previousButtonProps,
|
|
@@ -9038,15 +9060,16 @@ function Calendar({
|
|
|
9038
9060
|
return normalizedValue === null ? { start: null, end: null } : isDate(normalizedValue) ? { start: normalizedValue, end: null } : Array.isArray(normalizedValue) ? normalizedValue.length === 0 ? { start: null, end: null } : { start: min(normalizedValue), end: max(normalizedValue) } : normalizedValue;
|
|
9039
9061
|
}
|
|
9040
9062
|
}, [normalizedValue, selectionMode]);
|
|
9041
|
-
const firstSelectedDate = selectionMode === "none" ? void 0 : selectionMode === "single" ? value ?? void 0 : selectionMode === "multiple" ? value[0] : value.start ?? value.end ?? void 0;
|
|
9042
9063
|
const [focusedRange, setFocusedRange] = useState({
|
|
9043
9064
|
start: null,
|
|
9044
9065
|
end: null
|
|
9045
9066
|
});
|
|
9067
|
+
minMonth = useMemo(() => toValidDate(minMonth), [minMonth]);
|
|
9068
|
+
maxMonth = useMemo(() => toValidDate(maxMonth), [maxMonth]);
|
|
9046
9069
|
const minAllowedDate = useMemo(() => {
|
|
9047
9070
|
const minDates = [
|
|
9048
9071
|
toValidDate(minDate),
|
|
9049
|
-
|
|
9072
|
+
minMonth && startOfMonth(minMonth),
|
|
9050
9073
|
minYear != null && new Date(minYear, 0, 1)
|
|
9051
9074
|
].filter((d) => d);
|
|
9052
9075
|
return minDates.length > 0 ? max(minDates) : void 0;
|
|
@@ -9054,16 +9077,70 @@ function Calendar({
|
|
|
9054
9077
|
const maxAllowedDate = useMemo(() => {
|
|
9055
9078
|
const maxDates = [
|
|
9056
9079
|
toValidDate(maxDate),
|
|
9057
|
-
|
|
9080
|
+
maxMonth && endOfMonth(maxMonth),
|
|
9058
9081
|
maxYear != null && new Date(maxYear, 11, 31)
|
|
9059
9082
|
].filter((d) => d);
|
|
9060
9083
|
return maxDates.length > 0 ? min(maxDates) : void 0;
|
|
9061
9084
|
}, [maxDate, maxMonth, maxYear]);
|
|
9062
|
-
const
|
|
9063
|
-
const
|
|
9064
|
-
|
|
9085
|
+
const curDateStr = (/* @__PURE__ */ new Date()).toISOString();
|
|
9086
|
+
const curMonth = useMemo(
|
|
9087
|
+
() => startOfMonth(new Date(curDateStr)),
|
|
9088
|
+
[curDateStr]
|
|
9089
|
+
);
|
|
9090
|
+
const initialMonth = useMemo(() => {
|
|
9091
|
+
if (controlledMonth !== void 0) {
|
|
9092
|
+
return controlledMonth;
|
|
9093
|
+
}
|
|
9094
|
+
if (defaultMonth !== void 0) {
|
|
9095
|
+
return defaultMonth;
|
|
9096
|
+
}
|
|
9097
|
+
const selectedMonth = selectionMode === "none" ? null : selectionMode === "single" ? value : selectionMode === "multiple" ? value[0] : selectionMode === "range-end" ? value.end ?? value.start : value.start ?? value.end;
|
|
9098
|
+
if (selectedMonth != null) {
|
|
9099
|
+
return selectedMonth;
|
|
9100
|
+
}
|
|
9101
|
+
const minAllowedMonth = minAllowedDate && startOfMonth(minAllowedDate);
|
|
9102
|
+
const maxAllowedMonth = maxAllowedDate && startOfMonth(maxAllowedDate);
|
|
9103
|
+
return (!minAllowedMonth || !isBefore(curMonth, minAllowedMonth)) && (!maxAllowedMonth || !isAfter(curMonth, maxAllowedMonth)) ? curMonth : minAllowedMonth ?? maxAllowedMonth ?? curMonth;
|
|
9104
|
+
}, [
|
|
9105
|
+
controlledMonth,
|
|
9106
|
+
curMonth,
|
|
9107
|
+
defaultMonth,
|
|
9108
|
+
maxAllowedDate,
|
|
9109
|
+
minAllowedDate,
|
|
9110
|
+
selectionMode,
|
|
9111
|
+
value
|
|
9112
|
+
]);
|
|
9113
|
+
const [unnormalizedMonth, setMonth2] = useControllableState(
|
|
9114
|
+
initialMonth,
|
|
9065
9115
|
controlledMonth
|
|
9066
9116
|
);
|
|
9117
|
+
const month = useMemo(
|
|
9118
|
+
() => toValidDate(unnormalizedMonth) ?? curMonth,
|
|
9119
|
+
[curMonth, unnormalizedMonth]
|
|
9120
|
+
);
|
|
9121
|
+
const latest = useLatestValues({ value, month, numberOfMonths });
|
|
9122
|
+
useImperativeHandle(
|
|
9123
|
+
apiRef,
|
|
9124
|
+
() => ({
|
|
9125
|
+
getValue: () => latest.value,
|
|
9126
|
+
setValue,
|
|
9127
|
+
getMonth: () => latest.month,
|
|
9128
|
+
setMonth: setMonth2,
|
|
9129
|
+
isVisible: (date) => {
|
|
9130
|
+
const validDate = toValidDate(date);
|
|
9131
|
+
if (!validDate) {
|
|
9132
|
+
throw new Error(`Invalid date argument: ${date.toString()}`);
|
|
9133
|
+
}
|
|
9134
|
+
return isWithinInterval(validDate, {
|
|
9135
|
+
start: latest.month,
|
|
9136
|
+
end: lastDayOfMonth(
|
|
9137
|
+
addMonths(latest.month, (latest.numberOfMonths ?? 1) - 1)
|
|
9138
|
+
)
|
|
9139
|
+
});
|
|
9140
|
+
}
|
|
9141
|
+
}),
|
|
9142
|
+
[latest, setMonth2, setValue]
|
|
9143
|
+
);
|
|
9067
9144
|
const handleMonthChange = useCallback(
|
|
9068
9145
|
(date) => {
|
|
9069
9146
|
onMonthChange?.(date);
|
|
@@ -9117,7 +9194,7 @@ function Calendar({
|
|
|
9117
9194
|
}
|
|
9118
9195
|
}
|
|
9119
9196
|
if (modifiers2.outside) {
|
|
9120
|
-
const firstDay = startOfMonth(
|
|
9197
|
+
const firstDay = startOfMonth(unnormalizedMonth);
|
|
9121
9198
|
const lastDay = lastDayOfMonth(addMonths(firstDay, numberOfMonths - 1));
|
|
9122
9199
|
if (isBefore(date, firstDay)) {
|
|
9123
9200
|
handleMonthChange(
|
|
@@ -9132,7 +9209,7 @@ function Calendar({
|
|
|
9132
9209
|
},
|
|
9133
9210
|
[
|
|
9134
9211
|
handleMonthChange,
|
|
9135
|
-
|
|
9212
|
+
unnormalizedMonth,
|
|
9136
9213
|
numberOfMonths,
|
|
9137
9214
|
onDayClick,
|
|
9138
9215
|
onValueChange,
|
|
@@ -9225,7 +9302,6 @@ function Calendar({
|
|
|
9225
9302
|
locale: locale7.dayPickerLocale,
|
|
9226
9303
|
required,
|
|
9227
9304
|
disabled: composedDisabled,
|
|
9228
|
-
selected: firstSelectedDate,
|
|
9229
9305
|
components: {
|
|
9230
9306
|
MonthCaption: CalendarHeader,
|
|
9231
9307
|
MonthGrid: CalendarMonthGrid,
|
|
@@ -9698,6 +9774,7 @@ const DateInput = forwardRef(
|
|
|
9698
9774
|
open: false,
|
|
9699
9775
|
modal: false
|
|
9700
9776
|
});
|
|
9777
|
+
const calendarApiRef = useRef(null);
|
|
9701
9778
|
const inputRef = useRef(null);
|
|
9702
9779
|
const clearButtonRef = useRef(null);
|
|
9703
9780
|
const addonButtonRef = useRef(null);
|
|
@@ -9713,60 +9790,27 @@ const DateInput = forwardRef(
|
|
|
9713
9790
|
},
|
|
9714
9791
|
[onPopoverOpenChange, popoverState.open]
|
|
9715
9792
|
);
|
|
9716
|
-
const monthToDisplay = useCallback(
|
|
9717
|
-
() => startOfMonth(calendarProps?.defaultMonth ?? dateValue ?? /* @__PURE__ */ new Date()),
|
|
9718
|
-
[calendarProps?.defaultMonth, dateValue]
|
|
9719
|
-
);
|
|
9720
|
-
const [month, setMonth2] = useControllableState(
|
|
9721
|
-
() => monthToDisplay(),
|
|
9722
|
-
calendarProps?.month
|
|
9723
|
-
);
|
|
9724
|
-
const dateIsVisible = useCallback(
|
|
9725
|
-
(date) => isWithinInterval(date, {
|
|
9726
|
-
start: month,
|
|
9727
|
-
end: lastDayOfMonth(
|
|
9728
|
-
addMonths(month, (calendarProps?.numberOfMonths ?? 1) - 1)
|
|
9729
|
-
)
|
|
9730
|
-
}),
|
|
9731
|
-
[calendarProps?.numberOfMonths, month]
|
|
9732
|
-
);
|
|
9733
|
-
const handleMonthChange = combineEventHandlers(
|
|
9734
|
-
calendarProps?.onMonthChange,
|
|
9735
|
-
setMonth2
|
|
9736
|
-
);
|
|
9737
9793
|
const handleInputChange = useCallback(
|
|
9738
9794
|
(evt) => {
|
|
9739
9795
|
const formattedValue2 = evt.currentTarget.value;
|
|
9740
9796
|
const dateValue2 = parseDate(formattedValue2);
|
|
9741
9797
|
onValueChange?.({ formattedValue: formattedValue2, dateValue: dateValue2 });
|
|
9742
9798
|
setFormattedValue(formattedValue2);
|
|
9743
|
-
|
|
9744
|
-
|
|
9799
|
+
const calendarApi = calendarApiRef.current;
|
|
9800
|
+
if (!evt.defaultPrevented && dateValue2 && calendarApi && !calendarApi?.isVisible(dateValue2)) {
|
|
9801
|
+
const month = startOfMonth(dateValue2);
|
|
9802
|
+
calendarProps?.onMonthChange?.(month);
|
|
9803
|
+
calendarApi.setMonth(month);
|
|
9745
9804
|
}
|
|
9746
9805
|
},
|
|
9747
|
-
[
|
|
9748
|
-
dateIsVisible,
|
|
9749
|
-
handleMonthChange,
|
|
9750
|
-
onValueChange,
|
|
9751
|
-
parseDate,
|
|
9752
|
-
setFormattedValue
|
|
9753
|
-
]
|
|
9806
|
+
[calendarProps, onValueChange, parseDate, setFormattedValue]
|
|
9754
9807
|
);
|
|
9755
9808
|
const handleInputFocus = useCallback(() => {
|
|
9756
|
-
if (!popoverState.open) {
|
|
9757
|
-
handleMonthChange(monthToDisplay());
|
|
9758
|
-
}
|
|
9759
9809
|
changePopoverState({ open: true, modal: false });
|
|
9760
|
-
}, [
|
|
9761
|
-
popoverState.open,
|
|
9762
|
-
changePopoverState,
|
|
9763
|
-
handleMonthChange,
|
|
9764
|
-
monthToDisplay
|
|
9765
|
-
]);
|
|
9810
|
+
}, [changePopoverState]);
|
|
9766
9811
|
const handleAddonButtonClick = useCallback(() => {
|
|
9767
|
-
handleMonthChange(monthToDisplay());
|
|
9768
9812
|
changePopoverState({ open: true, modal: true });
|
|
9769
|
-
}, [changePopoverState
|
|
9813
|
+
}, [changePopoverState]);
|
|
9770
9814
|
const handleCalendarValueChange = useCallback(
|
|
9771
9815
|
(date) => {
|
|
9772
9816
|
const formattedValue2 = formatDate(date);
|
|
@@ -9931,8 +9975,6 @@ const DateInput = forwardRef(
|
|
|
9931
9975
|
selectionMode: "single",
|
|
9932
9976
|
value: deferredDateValue,
|
|
9933
9977
|
onValueChange: handleCalendarValueChange,
|
|
9934
|
-
month,
|
|
9935
|
-
onMonthChange: handleMonthChange,
|
|
9936
9978
|
disabled: disabled || softDisabled || readOnly || calendarProps?.disabled,
|
|
9937
9979
|
minDate,
|
|
9938
9980
|
maxDate,
|
|
@@ -9940,6 +9982,7 @@ const DateInput = forwardRef(
|
|
|
9940
9982
|
maxMonth,
|
|
9941
9983
|
minYear,
|
|
9942
9984
|
maxYear,
|
|
9985
|
+
apiRef: calendarApiRef,
|
|
9943
9986
|
monthSelectProps: {
|
|
9944
9987
|
...calendarProps?.monthSelectProps,
|
|
9945
9988
|
popoverProps: {
|
|
@@ -10102,6 +10145,7 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10102
10145
|
open: false,
|
|
10103
10146
|
modal: false
|
|
10104
10147
|
});
|
|
10148
|
+
const calendarApiRef = useRef(null);
|
|
10105
10149
|
const startContainerRef = useRef(null);
|
|
10106
10150
|
const endContainerRef = useRef(null);
|
|
10107
10151
|
const startInputRef = useRef(null);
|
|
@@ -10121,43 +10165,6 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10121
10165
|
},
|
|
10122
10166
|
[onPopoverOpenChange, popoverState.open, selectionMode]
|
|
10123
10167
|
);
|
|
10124
|
-
const monthToDisplay = useCallback(
|
|
10125
|
-
(input) => {
|
|
10126
|
-
let toDisplay;
|
|
10127
|
-
if (calendarProps?.defaultMonth) {
|
|
10128
|
-
toDisplay = calendarProps.defaultMonth;
|
|
10129
|
-
} else if (input === "start" && dateValue.start) {
|
|
10130
|
-
toDisplay = dateValue.start;
|
|
10131
|
-
} else {
|
|
10132
|
-
const relevantForEnd = dateValue.end && addMonths(dateValue.end, -(calendarProps?.numberOfMonths ?? 1) + 1);
|
|
10133
|
-
toDisplay = relevantForEnd ?? dateValue.start ?? /* @__PURE__ */ new Date();
|
|
10134
|
-
}
|
|
10135
|
-
return startOfMonth(toDisplay);
|
|
10136
|
-
},
|
|
10137
|
-
[
|
|
10138
|
-
dateValue.end,
|
|
10139
|
-
dateValue.start,
|
|
10140
|
-
calendarProps?.defaultMonth,
|
|
10141
|
-
calendarProps?.numberOfMonths
|
|
10142
|
-
]
|
|
10143
|
-
);
|
|
10144
|
-
const [month, setMonth2] = useControllableState(
|
|
10145
|
-
() => monthToDisplay("start"),
|
|
10146
|
-
calendarProps?.month
|
|
10147
|
-
);
|
|
10148
|
-
const dateIsVisible = useCallback(
|
|
10149
|
-
(date) => isWithinInterval(date, {
|
|
10150
|
-
start: month,
|
|
10151
|
-
end: lastDayOfMonth(
|
|
10152
|
-
addMonths(month, (calendarProps?.numberOfMonths ?? 1) - 1)
|
|
10153
|
-
)
|
|
10154
|
-
}),
|
|
10155
|
-
[calendarProps?.numberOfMonths, month]
|
|
10156
|
-
);
|
|
10157
|
-
const handleMonthChange = combineEventHandlers(
|
|
10158
|
-
calendarProps?.onMonthChange,
|
|
10159
|
-
setMonth2
|
|
10160
|
-
);
|
|
10161
10168
|
const handleStartInputChange = useCallback(
|
|
10162
10169
|
(evt) => {
|
|
10163
10170
|
const formattedStart = evt.currentTarget.value;
|
|
@@ -10172,18 +10179,20 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10172
10179
|
dateValue: newDateValue
|
|
10173
10180
|
});
|
|
10174
10181
|
setFormattedValue(newFormattedValue);
|
|
10175
|
-
|
|
10176
|
-
|
|
10182
|
+
const calendarApi = calendarApiRef.current;
|
|
10183
|
+
if (!evt.defaultPrevented && dateStart && calendarApi && !calendarApi.isVisible(dateStart)) {
|
|
10184
|
+
const month = startOfMonth(dateStart);
|
|
10185
|
+
calendarProps?.onMonthChange?.(month);
|
|
10186
|
+
calendarApi.setMonth(month);
|
|
10177
10187
|
}
|
|
10178
10188
|
},
|
|
10179
10189
|
[
|
|
10180
|
-
|
|
10190
|
+
parseDate,
|
|
10191
|
+
formattedValue.end,
|
|
10181
10192
|
dateValue.end,
|
|
10182
|
-
handleMonthChange,
|
|
10183
10193
|
onValueChange,
|
|
10184
|
-
parseDate,
|
|
10185
10194
|
setFormattedValue,
|
|
10186
|
-
|
|
10195
|
+
calendarProps
|
|
10187
10196
|
]
|
|
10188
10197
|
);
|
|
10189
10198
|
const handleEndInputChange = useCallback(
|
|
@@ -10200,24 +10209,23 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10200
10209
|
dateValue: newDateValue
|
|
10201
10210
|
});
|
|
10202
10211
|
setFormattedValue(newFormattedValue);
|
|
10203
|
-
|
|
10204
|
-
|
|
10205
|
-
|
|
10206
|
-
|
|
10207
|
-
|
|
10208
|
-
)
|
|
10212
|
+
const calendarApi = calendarApiRef.current;
|
|
10213
|
+
if (!evt.defaultPrevented && dateEnd && calendarApi && !calendarApi.isVisible(dateEnd)) {
|
|
10214
|
+
const month = addMonths(
|
|
10215
|
+
startOfMonth(dateEnd),
|
|
10216
|
+
-(calendarProps?.numberOfMonths ?? 1) + 1
|
|
10209
10217
|
);
|
|
10218
|
+
calendarProps?.onMonthChange?.(month);
|
|
10219
|
+
calendarApi.setMonth(month);
|
|
10210
10220
|
}
|
|
10211
10221
|
},
|
|
10212
10222
|
[
|
|
10213
|
-
|
|
10223
|
+
parseDate,
|
|
10224
|
+
formattedValue.start,
|
|
10214
10225
|
dateValue.start,
|
|
10215
|
-
calendarProps?.numberOfMonths,
|
|
10216
|
-
handleMonthChange,
|
|
10217
10226
|
onValueChange,
|
|
10218
|
-
parseDate,
|
|
10219
10227
|
setFormattedValue,
|
|
10220
|
-
|
|
10228
|
+
calendarProps
|
|
10221
10229
|
]
|
|
10222
10230
|
);
|
|
10223
10231
|
const handleInputFocus = useCallback(
|
|
@@ -10225,19 +10233,10 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10225
10233
|
setFieldControlFocused(true);
|
|
10226
10234
|
setSelectionMode(input);
|
|
10227
10235
|
if (!evt.defaultPrevented) {
|
|
10228
|
-
if (!popoverState.open) {
|
|
10229
|
-
handleMonthChange(monthToDisplay(input));
|
|
10230
|
-
}
|
|
10231
10236
|
changePopoverState({ open: true, modal: false });
|
|
10232
10237
|
}
|
|
10233
10238
|
},
|
|
10234
|
-
[
|
|
10235
|
-
setFieldControlFocused,
|
|
10236
|
-
popoverState.open,
|
|
10237
|
-
changePopoverState,
|
|
10238
|
-
handleMonthChange,
|
|
10239
|
-
monthToDisplay
|
|
10240
|
-
]
|
|
10239
|
+
[setFieldControlFocused, changePopoverState]
|
|
10241
10240
|
);
|
|
10242
10241
|
const handleClearButtonClick = useCallback(
|
|
10243
10242
|
(ref) => () => {
|
|
@@ -10272,9 +10271,8 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10272
10271
|
);
|
|
10273
10272
|
const handleAddonButtonClick = useCallback(() => {
|
|
10274
10273
|
setSelectionMode("start");
|
|
10275
|
-
handleMonthChange(monthToDisplay("start"));
|
|
10276
10274
|
changePopoverState({ open: true, modal: true });
|
|
10277
|
-
}, [
|
|
10275
|
+
}, [changePopoverState]);
|
|
10278
10276
|
const handleCalendarValueChange = useCallback(
|
|
10279
10277
|
(range) => {
|
|
10280
10278
|
const newFormattedValue = {
|
|
@@ -10745,8 +10743,6 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10745
10743
|
selectionMode: `range-${selectionMode}`,
|
|
10746
10744
|
value: deferredDateValue,
|
|
10747
10745
|
onValueChange: handleCalendarValueChange,
|
|
10748
|
-
month,
|
|
10749
|
-
onMonthChange: handleMonthChange,
|
|
10750
10746
|
disabled: bothDisabled || bothSoftDisabled || bothReadOnly || (startDisabled || startSoftDisabled || startReadOnly) && (endDisabled || endSoftDisabled || endReadOnly) || calendarProps?.disabled,
|
|
10751
10747
|
minDate,
|
|
10752
10748
|
maxDate,
|
|
@@ -10754,6 +10750,7 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
|
|
|
10754
10750
|
maxMonth,
|
|
10755
10751
|
minYear,
|
|
10756
10752
|
maxYear,
|
|
10753
|
+
apiRef: calendarApiRef,
|
|
10757
10754
|
monthSelectProps: {
|
|
10758
10755
|
...calendarProps?.monthSelectProps,
|
|
10759
10756
|
popoverProps: {
|