import React, { useRef, useState } from 'react'; import { NumericField } from '@lendi/ui/NumericField'; import { Button } from '@lendi/ui/Button'; import { Spacer } from '@lendi/ui/Layout'; export const Interactive = (args) => ; Interactive.args = { label: 'Label text', }; Interactive.argTypes = { inlineAction: { control: { type: 'radio', options: ['clear'] }, }, }; export const ClearAction = () => { const [value, setValue] = useState(); const inputRef = useRef(); const handleOnChange = (event) => { console.info('value', event.target.value); setValue(event.target.value); }; return ( ); }; export const ClearActionWithValue = () => { const defaultValue = 123456789101112131415; const [value, setValue] = useState(defaultValue); const inputRef = useRef(); const handleOnChange = (event) => { console.info('value', event.target.value); setValue(event.target.value); }; return ( ); }; export const Controlled = (args) => { const [value, setValue] = useState(undefined); const handleOnChange = (event) => { console.info('value', event.target.value); setValue(event.target.value); }; const handleOnValueChange = (value) => { console.info('value', value); }; return ; }; Controlled.args = { label: 'Label', placeholder: 'Placeholder text', helpText: 'Help text', }; export const Uncontrolled = () => { const inputRef = useRef(null); const showVal = () => { console.log('RawValue', inputRef.current.value); }; return ( ); }; export const Errors = () => ( ); export const Labels = () => ( ); export const Widths = () => ( ); export const Validation = () => { const [validationState, setValidationState] = useState<'valid' | 'invalid'>('valid'); const handleChange = (e) => { if (e.target.validity.patternMismatch) { console.log(e.target.validity); setValidationState('invalid'); } else { setValidationState('valid'); } }; return ( ); };