// Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React, { useState } from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './Input'; import { Input } from './Input'; import { setupI18n } from '../util/setupI18n'; import enMessages from '../../_locales/en/messages.json'; const i18n = setupI18n('en', enMessages); export default { title: 'Components/Input', argTypes: {}, args: {}, } satisfies Meta; const createProps = (overrideProps: Partial = {}): PropsType => ({ disabled: Boolean(overrideProps.disabled), disableSpellcheck: overrideProps.disableSpellcheck, expandable: Boolean(overrideProps.expandable), hasClearButton: Boolean(overrideProps.hasClearButton), i18n, icon: overrideProps.icon, maxLengthCount: overrideProps.maxLengthCount, onChange: action('onChange'), placeholder: overrideProps.placeholder ?? 'Enter some text here', value: overrideProps.value ?? '', whenToShowRemainingCount: overrideProps.whenToShowRemainingCount, }); function Controller(props: PropsType): JSX.Element { const { value: initialValue } = props; const [value, setValue] = useState(initialValue); return ; } export function Simple(): JSX.Element { return ; } export function HasClearButton(): JSX.Element { return ( ); } export function CharacterCount(): JSX.Element { return ( ); } export function CharacterCountCustomizableShow(): JSX.Element { return ( ); } export function Expandable(): JSX.Element { return ( ); } export function ExpandableWCount(): JSX.Element { return ( ); } export function Disabled(): JSX.Element { return ( ); } export function SpellcheckDisabled(): JSX.Element { return ( ); }