Skip to content

Commit

Permalink
add interactable teltextfield variant
Browse files Browse the repository at this point in the history
  • Loading branch information
mastercactapus committed Jan 5, 2024
1 parent ee14afb commit 111713d
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react'
import type { Meta, StoryObj } from '@storybook/react'
import TelTextField from './TelTextField'
import { HttpResponse, graphql } from 'msw'
Expand Down Expand Up @@ -71,3 +72,31 @@ export const InvalidNumber: Story = {
await expect(await canvas.findByTestId('CloseIcon')).toBeVisible()
},
}

export const Interactable: Story = {
args: {
value: '+1763555012',
label: 'Phone Number',
error: false,
},

render: function Interactable(args) {
const { value, onChange, ...props } = args
const [valueState, setValueState] = React.useState(value)

React.useEffect(() => {
setValueState(value)
}, [value])

return (
<TelTextField
{...props}
value={valueState}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
if (onChange) onChange(e)
setValueState(e.target.value)
}}
/>
)
},
}

0 comments on commit 111713d

Please sign in to comment.