Blame view

天文台pc/tianwentai-ui/node_modules/react-day-picker/src/components/Day/Day.tsx 837 Bytes
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  import { useRef } from 'react';
  
  import { useDayRender } from 'hooks/useDayRender';
  
  import { Button } from '../Button';
  
  /** Represent the props used by the {@link Day} component. */
  export interface DayProps {
    /** The month where the date is displayed. */
    displayMonth: Date;
    /** The date to render. */
    date: Date;
  }
  
  /**
   * The content of a day cell – as a button or span element according to its
   * modifiers.
   */
  export function Day(props: DayProps): JSX.Element {
    const buttonRef = useRef<HTMLButtonElement>(null);
    const dayRender = useDayRender(props.date, props.displayMonth, buttonRef);
  
    if (dayRender.isHidden) {
      return <div role="gridcell"></div>;
    }
    if (!dayRender.isButton) {
      return <div {...dayRender.divProps} />;
    }
    return <Button name="day" ref={buttonRef} {...dayRender.buttonProps} />;
  }