import { useState } from 'react'; import type { Meta, StoryObj } from '@storybook/react-vite'; import { Typography } from 'antd'; import dayjs from 'dayjs'; import type { Dayjs } from 'dayjs'; import { setDatepicker } from '@/hooks/useDatepicker'; import { ThemeProvider } from '@/hooks/useTheme'; import DateTimePicker from './DateTimePicker'; setDatepicker('gregorian'); function ClientExpiryDemo() { const [value, setValue] = useState(dayjs('2026-12-31 23:59:59')); return (
{value ? `user1@node-de expiryTime: ${value.valueOf()}` : 'user1@node-de expiryTime: 0 (never expires)'}
); } const meta = { title: 'Form/DateTimePicker', component: DateTimePicker, tags: ['autodocs'], parameters: { layout: 'padded', docs: { description: { component: 'Date/time picker used for client and inbound expiry dates, rendered with the AntD DatePicker.', }, }, }, decorators: [ (Story) => ( ), ], argTypes: { value: { description: 'Selected moment as a Dayjs instance, or null when unset.' }, onChange: { description: 'Called with the picked Dayjs value, or null when cleared.' }, showTime: { description: 'Include an hour/minute/second selector alongside the date.' }, format: { description: 'Display format for the Gregorian picker input.' }, placeholder: { description: 'Input placeholder shown while no value is set.' }, disabled: { description: 'Disables the input and hides the clear button.' }, }, } satisfies Meta; export default meta; type Story = StoryObj; export const Empty: Story = { args: { value: null, onChange: () => undefined, placeholder: 'Leave blank to never expire', }, }; export const ClientExpiry: Story = { args: { value: null, onChange: () => undefined }, render: () => , }; export const DateOnly: Story = { args: { value: dayjs('2026-08-01'), onChange: () => undefined, showTime: false, format: 'YYYY-MM-DD', placeholder: 'Start date', }, };