@lumx/react 4.23.1-alpha.0 → 4.24.0-next.0
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 +20 -38
- package/index.js.map +1 -1
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -22577,7 +22577,7 @@ function timeOfDayMinutes(date) {
|
|
|
22577
22577
|
/** Options for `buildTimeList`. */
|
|
22578
22578
|
|
|
22579
22579
|
const MINUTES_IN_HOUR = 60;
|
|
22580
|
-
const MINUTES_IN_DAY
|
|
22580
|
+
const MINUTES_IN_DAY = 24 * MINUTES_IN_HOUR;
|
|
22581
22581
|
|
|
22582
22582
|
/**
|
|
22583
22583
|
* Build a full-day list of `TimeOfDay` entries spaced `step` minutes apart.
|
|
@@ -22597,7 +22597,7 @@ function buildTimeList(options = {}) {
|
|
|
22597
22597
|
const minMinutes = minTime ? timeOfDayMinutes(minTime) : undefined;
|
|
22598
22598
|
const maxMinutes = maxTime ? timeOfDayMinutes(maxTime) : undefined;
|
|
22599
22599
|
const list = [];
|
|
22600
|
-
for (let minutes = 0; minutes < MINUTES_IN_DAY
|
|
22600
|
+
for (let minutes = 0; minutes < MINUTES_IN_DAY; minutes += step) {
|
|
22601
22601
|
const hour = Math.floor(minutes / MINUTES_IN_HOUR);
|
|
22602
22602
|
const minute = minutes % MINUTES_IN_HOUR;
|
|
22603
22603
|
const outOfRange = minMinutes !== undefined && minutes < minMinutes || maxMinutes !== undefined && minutes > maxMinutes || undefined;
|
|
@@ -22663,42 +22663,24 @@ function parseTimeInput(raw) {
|
|
|
22663
22663
|
};
|
|
22664
22664
|
}
|
|
22665
22665
|
|
|
22666
|
-
const MINUTES_IN_DAY = 24 * 60;
|
|
22667
|
-
function ceilToStep(minutes, step) {
|
|
22668
|
-
return Math.ceil(minutes / step) * step;
|
|
22669
|
-
}
|
|
22670
|
-
function floorToStep(minutes, step) {
|
|
22671
|
-
return Math.floor(minutes / step) * step;
|
|
22672
|
-
}
|
|
22673
|
-
function minutesToTimeOfDay(minutes) {
|
|
22674
|
-
return {
|
|
22675
|
-
hour: Math.floor(minutes / 60),
|
|
22676
|
-
minute: minutes % 60
|
|
22677
|
-
};
|
|
22678
|
-
}
|
|
22679
|
-
|
|
22680
22666
|
/**
|
|
22681
|
-
* Clamp `time` to `[minTime, maxTime]
|
|
22682
|
-
*
|
|
22683
|
-
*
|
|
22684
|
-
* effective `maxTime` snap down to it. Others are returned unchanged. When no
|
|
22685
|
-
* `step`-aligned option exists inside `[minTime, maxTime]`, `time` is returned
|
|
22686
|
-
* unchanged since there is nothing to snap to. Only the time-of-day of
|
|
22687
|
-
* `minTime`/`maxTime` is used.
|
|
22667
|
+
* Clamp `time` to `[minTime, maxTime]`. Inputs strictly before `minTime` snap
|
|
22668
|
+
* up; inputs strictly after `maxTime` snap down; otherwise returned unchanged.
|
|
22669
|
+
* Only the time-of-day of `minTime`/`maxTime` is used.
|
|
22688
22670
|
*/
|
|
22689
|
-
function snapTimeToBounds(time, minTime, maxTime
|
|
22671
|
+
function snapTimeToBounds(time, minTime, maxTime) {
|
|
22690
22672
|
const totalMinutes = time.hour * 60 + time.minute;
|
|
22691
|
-
|
|
22692
|
-
|
|
22693
|
-
|
|
22694
|
-
|
|
22695
|
-
|
|
22696
|
-
}
|
|
22697
|
-
if (effectiveMin !== undefined && totalMinutes < effectiveMin) {
|
|
22698
|
-
return minutesToTimeOfDay(effectiveMin);
|
|
22673
|
+
if (minTime && totalMinutes < timeOfDayMinutes(minTime)) {
|
|
22674
|
+
return {
|
|
22675
|
+
hour: minTime.getHours(),
|
|
22676
|
+
minute: minTime.getMinutes()
|
|
22677
|
+
};
|
|
22699
22678
|
}
|
|
22700
|
-
if (
|
|
22701
|
-
return
|
|
22679
|
+
if (maxTime && totalMinutes > timeOfDayMinutes(maxTime)) {
|
|
22680
|
+
return {
|
|
22681
|
+
hour: maxTime.getHours(),
|
|
22682
|
+
minute: maxTime.getMinutes()
|
|
22683
|
+
};
|
|
22702
22684
|
}
|
|
22703
22685
|
return time;
|
|
22704
22686
|
}
|
|
@@ -22777,11 +22759,11 @@ const TimePickerField = props => {
|
|
|
22777
22759
|
hour: value.getHours(),
|
|
22778
22760
|
minute: value.getMinutes()
|
|
22779
22761
|
};
|
|
22780
|
-
const clamped = snapTimeToBounds(timeOfDay, minTime, maxTime
|
|
22762
|
+
const clamped = snapTimeToBounds(timeOfDay, minTime, maxTime);
|
|
22781
22763
|
if (clamped.hour !== value.getHours() || clamped.minute !== value.getMinutes()) {
|
|
22782
22764
|
onChange(getDateAtTime(clamped, value), name);
|
|
22783
22765
|
}
|
|
22784
|
-
}, [boundsMode, value,
|
|
22766
|
+
}, [boundsMode, value, minTime, maxTime, onChange, name]);
|
|
22785
22767
|
const handleChange = useCallback(next => {
|
|
22786
22768
|
const date = next ? getDateAtTime(next, value) : undefined;
|
|
22787
22769
|
onChange(date, name);
|
|
@@ -22794,10 +22776,10 @@ const TimePickerField = props => {
|
|
|
22794
22776
|
if (!parsed) return;
|
|
22795
22777
|
|
|
22796
22778
|
// Snap to bounds if needed, then dedup against the current value.
|
|
22797
|
-
const time = snapTimeToBounds(parsed, minTime, maxTime
|
|
22779
|
+
const time = snapTimeToBounds(parsed, minTime, maxTime);
|
|
22798
22780
|
if (value && isDateOnTime(value, time)) return;
|
|
22799
22781
|
onChange(getDateAtTime(time, value), name);
|
|
22800
|
-
}, [maxTime, minTime, name, onChange, searchValue,
|
|
22782
|
+
}, [maxTime, minTime, name, onChange, searchValue, value]);
|
|
22801
22783
|
const searchInputValue = value ? formatTime(value, locale) : undefined;
|
|
22802
22784
|
return TimePickerField$1({
|
|
22803
22785
|
...forwardedProps,
|