@ostack.tech/ui 0.11.2 → 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 +20 -18
- package/dist/ostack-ui.js.map +1 -1
- package/package.json +1 -1
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,11 +8787,11 @@ const CalendarHeader = memo(function CalendarHeader2({
|
|
|
8787
8787
|
}
|
|
8788
8788
|
return months2;
|
|
8789
8789
|
}, []);
|
|
8790
|
-
const displayYear =
|
|
8791
|
-
const curYear =
|
|
8790
|
+
const displayYear = displayDate.getFullYear();
|
|
8791
|
+
const curYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
8792
8792
|
const nearestCentury = curYear + 50 - (curYear + 50) % 100;
|
|
8793
|
-
const minYear = minAllowedDate ?
|
|
8794
|
-
const maxYear = maxAllowedDate ?
|
|
8793
|
+
const minYear = minAllowedDate ? minAllowedDate.getFullYear() : Math.min(displayYear, nearestCentury - 100);
|
|
8794
|
+
const maxYear = maxAllowedDate ? maxAllowedDate.getFullYear() : Math.max(displayYear, nearestCentury + 99);
|
|
8795
8795
|
const yearDates = useMemo(() => {
|
|
8796
8796
|
const years = [];
|
|
8797
8797
|
if (displayYear < minYear) {
|
|
@@ -8873,23 +8873,25 @@ const CalendarHeader = memo(function CalendarHeader2({
|
|
|
8873
8873
|
})
|
|
8874
8874
|
}
|
|
8875
8875
|
);
|
|
8876
|
-
const monthOptions = useMemo(
|
|
8877
|
-
|
|
8876
|
+
const monthOptions = useMemo(() => {
|
|
8877
|
+
const minMonth = minAllowedDate?.getMonth();
|
|
8878
|
+
const maxMonth = maxAllowedDate?.getMonth();
|
|
8879
|
+
return monthDates.map((monthDate) => {
|
|
8880
|
+
const month = monthDate.getMonth();
|
|
8878
8881
|
return /* @__PURE__ */ jsx(
|
|
8879
8882
|
Option,
|
|
8880
8883
|
{
|
|
8881
|
-
value:
|
|
8882
|
-
disabled: minAllowedDate &&
|
|
8884
|
+
value: month,
|
|
8885
|
+
disabled: minAllowedDate && minAllowedDate.getFullYear() === maxAllowedDate?.getFullYear() && (month < minMonth || month > maxMonth),
|
|
8883
8886
|
children: format(monthDate, MONTH_FORMAT, { locale: locale7 })
|
|
8884
8887
|
},
|
|
8885
|
-
|
|
8888
|
+
month
|
|
8886
8889
|
);
|
|
8887
|
-
})
|
|
8888
|
-
|
|
8889
|
-
);
|
|
8890
|
+
});
|
|
8891
|
+
}, [locale7, maxAllowedDate, minAllowedDate, monthDates]);
|
|
8890
8892
|
const yearOptions = useMemo(
|
|
8891
8893
|
() => yearDates.map((yearDate) => {
|
|
8892
|
-
const year =
|
|
8894
|
+
const year = yearDate.getFullYear();
|
|
8893
8895
|
return /* @__PURE__ */ jsx(
|
|
8894
8896
|
Option,
|
|
8895
8897
|
{
|
|
@@ -8927,7 +8929,7 @@ const CalendarHeader = memo(function CalendarHeader2({
|
|
|
8927
8929
|
monthSelectProps?.onValueChange,
|
|
8928
8930
|
handleMonthChange
|
|
8929
8931
|
),
|
|
8930
|
-
value: getMonth(
|
|
8932
|
+
value: displayDate.getMonth(),
|
|
8931
8933
|
children: monthOptions
|
|
8932
8934
|
}
|
|
8933
8935
|
),
|
|
@@ -8945,7 +8947,7 @@ const CalendarHeader = memo(function CalendarHeader2({
|
|
|
8945
8947
|
yearSelectProps?.onValueChange,
|
|
8946
8948
|
handleYearChange
|
|
8947
8949
|
),
|
|
8948
|
-
value:
|
|
8950
|
+
value: displayDate.getFullYear(),
|
|
8949
8951
|
children: yearOptions
|
|
8950
8952
|
}
|
|
8951
8953
|
)
|