import { Fragment } from 'react'; import type { Meta, StoryObj } from '@storybook/react-webpack5'; import { Search } from '@transferwise/icons'; import { useRtlDiffI18n, withRTLDiff } from '../../../../.storybook/decorators/RtlDiffDecorator'; import Button from '../../../Button'; import { Input } from '../../Input/Input'; import { InputGroup } from '../InputGroup'; import { WithOverlaidAbsoluteElement } from '../../../../.storybook/components/WithOverlaidAbsoluteElement'; export default { component: InputGroup, title: 'Forms/InputGroup/Tests', tags: ['!autodocs', '!manifest'], } satisfies Meta; type Story = StoryObj; /** * InputGroup positions addons at the logical start or end of an input. * In RTL mode the start and end sides are mirrored, so an addonStart icon * should appear on the right and an addonEnd button should appear on the left. * All three placement combinations are included to verify each case. * * Each combination is also rendered with Latin and Arabic values: `dir="auto"` * can resolve the input opposite to the page, and the addons must not overlap the text. */ export const RTLDiff: Story = { render: () => { const i18n = useRtlDiffI18n(); return ( <> {[undefined, 'non-RTL value', 'مرحبا بالعالم'].map((value) => ( , initialContentWidth: 24, }} > {i18n.copy} ), interactive: true, padding: 'sm', }} > , initialContentWidth: 24, }} addonEnd={{ content: ( ), interactive: true, padding: 'sm', }} > ))} ); }, ...withRTLDiff({ fixedRows: { heights: 'auto' }, i18n: { placeholder_both: { en: 'addonStart and addonEnd', ar: 'البادئة والنهاية' }, placeholder_start: { en: 'addonStart only', ar: 'البادئة فقط' }, placeholder_end: { en: 'addonEnd only', ar: 'النهاية فقط' }, copy: { en: 'Copy', ar: 'نسخ' }, clear: { en: 'Clear', ar: 'مسح' }, }, }), }; export const StackingContext: Story = { render: () => ( , initialContentWidth: 24, }} > ), };