import * as React from "react";
import type { ComponentStory, ComponentMeta } from "@storybook/react";
import {DatePicker, DatePickerRefFuncProps} from "../src";
import {useRef} from "react";

export default {
  title: "lib/DatePicker",
  component: DatePicker,
} as ComponentMeta<typeof DatePicker>

const Template: ComponentStory<typeof DatePicker> = args => {
  const dp = useRef<DatePickerRefFuncProps>();
  
  return <div className='h-[320px]'>
    <button onClick={() => {
      dp?.current?.setSince('d')
      // dp?.current?.setDateRange([null, null])
    }}>clear dateRange</button>
    <DatePicker {...args} onRef={dp} onDateStrChange={s => {console.log('s', s)}} />
  </div>
}

export const Normal = Template.bind({});

export const TimeQuantum = Template.bind({});
TimeQuantum.args = {
  timeQuantum: true
}

export const QueryButton = Template.bind({});
QueryButton.args = {
  queryButton: true
}

export const ResetButton = Template.bind({});
ResetButton.args = {
  resetButton: true
}
