@dvrd/dvr-controls 1.0.67 → 1.0.68
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/package.json
CHANGED
|
@@ -104,7 +104,7 @@ export default function DvrdDatePicker(props: Props) {
|
|
|
104
104
|
alwaysShowArrows={alwaysShowArrows} max={max} min={min}/>
|
|
105
105
|
{!!timeMode &&
|
|
106
106
|
<TimePicker onChange={onChangeTimePicker} onClose={onClosePicker} value={value}
|
|
107
|
-
open={timePickerOpen} timeMode={timeMode}/>}
|
|
107
|
+
open={timePickerOpen} timeMode={timeMode} closeOnChange={closeOnChange}/>}
|
|
108
108
|
<label className='error-label'>{error}</label>
|
|
109
109
|
</div>
|
|
110
110
|
)
|
|
@@ -432,6 +432,7 @@ interface TimePickerProps {
|
|
|
432
432
|
value: IDate | null;
|
|
433
433
|
open: boolean;
|
|
434
434
|
timeMode: DatePickerTimeMode;
|
|
435
|
+
closeOnChange?: boolean;
|
|
435
436
|
}
|
|
436
437
|
|
|
437
438
|
type TimePartValues = [string, string, string, string, string, string];
|
|
@@ -450,7 +451,7 @@ function timePartsToNumber(part1: string, part2: string): number {
|
|
|
450
451
|
}
|
|
451
452
|
|
|
452
453
|
function TimePicker(props: TimePickerProps) {
|
|
453
|
-
const {onChange, value, open, onClose, timeMode} = props;
|
|
454
|
+
const {onChange, value, open, onClose, timeMode, closeOnChange} = props;
|
|
454
455
|
const [timeParts, setTimeParts] = useState<TimePartValues>(dateToTimeParts(value));
|
|
455
456
|
const secondHourMax = useMemo(() => {
|
|
456
457
|
if (Number(timeParts[0]) === 2) return 3;
|
|
@@ -460,14 +461,14 @@ function TimePicker(props: TimePickerProps) {
|
|
|
460
461
|
|
|
461
462
|
function onClickNow() {
|
|
462
463
|
setTimeParts(dateToTimeParts(new IDate()));
|
|
464
|
+
if (closeOnChange)
|
|
465
|
+
onSubmit();
|
|
463
466
|
}
|
|
464
467
|
|
|
465
468
|
function onSubmit() {
|
|
466
|
-
console.log(timeParts);
|
|
467
469
|
const hours = timePartsToNumber(timeParts[0], timeParts[1]);
|
|
468
470
|
const minutes = timePartsToNumber(timeParts[2], timeParts[3]);
|
|
469
471
|
const seconds = timePartsToNumber(timeParts[4], timeParts[5]);
|
|
470
|
-
console.log(hours, minutes, seconds);
|
|
471
472
|
const _value = value?.clone() ?? new IDate();
|
|
472
473
|
onChange(_value.set({hours, minutes, seconds}));
|
|
473
474
|
onClose();
|