import type { Meta, StoryObj } from '@storybook/react-webpack5'; import { userEvent, within } from 'storybook/test'; import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator'; import DateLookup from '..'; export default { component: DateLookup, title: 'Forms/DateLookup/Tests/RTL Diff', tags: ['!autodocs', '!manifest'], } satisfies Meta; type Story = StoryObj; const selectedDate = new Date(2024, 5, 14); const i18nConfig = { label: { en: 'Select date', ar: 'اختر التاريخ' }, placeholder: { en: 'Choose a date', ar: 'اختر تاريخًا' }, }; export const TriggerVariants: Story = { render: () => { const i18n = useRtlDiffI18n<{ label: string; placeholder: string }>(); return ( <> {}} /> {}} /> {}} /> {}} /> ); }, ...withRTLDiff({ renderAs: 'iframe', i18n: i18nConfig }), }; const containerStyle: React.CSSProperties = { display: 'flex', justifyContent: 'center', alignItems: 'flex-start', minHeight: '24rem', paddingTop: '2rem', width: '100%', }; export const OpenCalendarPanel: Story = { render: () => { const i18n = useRtlDiffI18n<{ label: string; placeholder: string }>(); return (
{}} />
); }, play: async ({ canvasElement }: { canvasElement: HTMLElement }) => { const canvas = within(canvasElement); const trigger = canvas.queryByRole('button'); if (!trigger) return; await userEvent.click(trigger); // Suppress focus ring on calendar cells — FocusScope traps focus inside the panel // and the autofocus cycle causes the selected date's ring to flicker between iframes. const style = canvasElement.ownerDocument.createElement('style'); style.textContent = ` .np-panel__content *:focus { outline: none !important; box-shadow: none !important; }`; canvasElement.ownerDocument.head.appendChild(style); }, ...withRTLDiff({ renderAs: 'iframe', i18n: i18nConfig }), };