All files / src/timepicker/_example TimePickerDisabledExample.jsx

28.57% Statements 2/7
0% Branches 0/2
16.67% Functions 1/6
28.57% Lines 2/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19      1x           1x                  
import React from "react";
import { TimePicker } from "@tencent/tea-component/lib/timepicker";
 
const range = (s, t) =>
  Array(t - s + 1)
    .fill(0)
    .map((_, i) => s + i);
 
export default () => {
  return (
    <TimePicker
      secondStep={30}
      disabledHours={() => [...range(0, 8), ...range(13, 14), ...range(18, 23)]}
      disabledMinutes={hour => (hour === 12 ? range(30, 59) : [])}
      onChange={value => console.log(value.format("HH:mm:ss"))}
    />
  );
};