|
| 1 | +import React from "react"; |
| 2 | +import { Meta, StoryFn } from "@storybook/nextjs"; |
| 3 | +import { useForm, FormProvider } from "react-hook-form"; |
| 4 | +import FormDateTimePickerInput, { |
| 5 | + DateTimePickerFieldProps, |
| 6 | +} from "./date-time-picker"; |
| 7 | + |
| 8 | +export default { |
| 9 | + title: "Components/Form/DateTimePickerInput", |
| 10 | + component: FormDateTimePickerInput, |
| 11 | +} as Meta; |
| 12 | + |
| 13 | +const Template: StoryFn<DateTimePickerFieldProps & { name: string }> = ( |
| 14 | + args |
| 15 | +) => { |
| 16 | + const methods = useForm({ |
| 17 | + defaultValues: { |
| 18 | + sampleDateTime: null, |
| 19 | + }, |
| 20 | + }); |
| 21 | + |
| 22 | + return ( |
| 23 | + <FormProvider {...methods}> |
| 24 | + <form> |
| 25 | + <FormDateTimePickerInput {...args} /> |
| 26 | + </form> |
| 27 | + </FormProvider> |
| 28 | + ); |
| 29 | +}; |
| 30 | + |
| 31 | +export const Default = Template.bind({}); |
| 32 | +Default.args = { |
| 33 | + label: "Sample Date Time Picker", |
| 34 | + name: "sampleDateTime", |
| 35 | + testId: "sampleDateTime", |
| 36 | +}; |
| 37 | + |
| 38 | +export const WithMinMaxDate = Template.bind({}); |
| 39 | +WithMinMaxDate.args = { |
| 40 | + label: "Date Time Picker with Min/Max", |
| 41 | + name: "sampleDateTime", |
| 42 | + minDate: new Date(2020, 0, 1), |
| 43 | + maxDate: new Date(2030, 11, 31), |
| 44 | + testId: "minMaxDateTime", |
| 45 | +}; |
| 46 | + |
| 47 | +export const Disabled = Template.bind({}); |
| 48 | +Disabled.args = { |
| 49 | + label: "Disabled Date Time Picker", |
| 50 | + name: "sampleDateTime", |
| 51 | + disabled: true, |
| 52 | + testId: "disabledDateTime", |
| 53 | +}; |
| 54 | + |
| 55 | +export const ReadOnly = Template.bind({}); |
| 56 | +ReadOnly.args = { |
| 57 | + label: "Read Only Date Time Picker", |
| 58 | + name: "sampleDateTime", |
| 59 | + readOnly: true, |
| 60 | + testId: "readOnlyDateTime", |
| 61 | +}; |
| 62 | + |
| 63 | +export const CustomViews = Template.bind({}); |
| 64 | +CustomViews.args = { |
| 65 | + label: "Custom Views Date Time Picker", |
| 66 | + name: "sampleDateTime", |
| 67 | + views: ["day", "hours", "minutes"], |
| 68 | + testId: "customViewsDateTime", |
| 69 | +}; |
0 commit comments