|
| 1 | +import type { Meta, StoryObj } from '@storybook/react'; |
| 2 | +import { TelephoneInput } from '@dsn/components-react'; |
| 3 | +import DocsPage from './TelephoneInput.docs.mdx'; |
| 4 | + |
| 5 | +const meta: Meta<typeof TelephoneInput> = { |
| 6 | + title: 'Components/TelephoneInput', |
| 7 | + component: TelephoneInput, |
| 8 | + parameters: { |
| 9 | + docs: { |
| 10 | + page: DocsPage, |
| 11 | + }, |
| 12 | + }, |
| 13 | + argTypes: { |
| 14 | + placeholder: { control: 'text' }, |
| 15 | + disabled: { control: 'boolean' }, |
| 16 | + readOnly: { control: 'boolean' }, |
| 17 | + invalid: { control: 'boolean' }, |
| 18 | + required: { control: 'boolean' }, |
| 19 | + width: { |
| 20 | + control: 'select', |
| 21 | + options: [undefined, 'xs', 'sm', 'md', 'lg', 'xl', 'full'], |
| 22 | + }, |
| 23 | + }, |
| 24 | + args: { |
| 25 | + placeholder: '06 12345678', |
| 26 | + disabled: false, |
| 27 | + readOnly: false, |
| 28 | + invalid: false, |
| 29 | + required: false, |
| 30 | + }, |
| 31 | +}; |
| 32 | + |
| 33 | +export default meta; |
| 34 | +type Story = StoryObj<typeof TelephoneInput>; |
| 35 | + |
| 36 | +export const Default: Story = {}; |
| 37 | + |
| 38 | +export const WithValue: Story = { |
| 39 | + name: 'With value', |
| 40 | + args: { |
| 41 | + defaultValue: '06 12345678', |
| 42 | + }, |
| 43 | +}; |
| 44 | + |
| 45 | +export const International: Story = { |
| 46 | + name: 'International format', |
| 47 | + args: { |
| 48 | + defaultValue: '+31 6 12345678', |
| 49 | + placeholder: '+31 6 12345678', |
| 50 | + }, |
| 51 | +}; |
| 52 | + |
| 53 | +export const Disabled: Story = { |
| 54 | + args: { |
| 55 | + disabled: true, |
| 56 | + value: '06 12345678', |
| 57 | + }, |
| 58 | +}; |
| 59 | + |
| 60 | +export const ReadOnly: Story = { |
| 61 | + name: 'Read-only', |
| 62 | + args: { |
| 63 | + readOnly: true, |
| 64 | + value: '06 12345678', |
| 65 | + }, |
| 66 | +}; |
| 67 | + |
| 68 | +export const Invalid: Story = { |
| 69 | + args: { |
| 70 | + invalid: true, |
| 71 | + value: 'geen nummer', |
| 72 | + }, |
| 73 | +}; |
| 74 | + |
| 75 | +export const Widths: Story = { |
| 76 | + name: 'Width variants', |
| 77 | + render: () => ( |
| 78 | + <div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}> |
| 79 | + <TelephoneInput width="xs" placeholder="xs" /> |
| 80 | + <TelephoneInput width="sm" placeholder="sm" /> |
| 81 | + <TelephoneInput width="md" placeholder="md" /> |
| 82 | + <TelephoneInput width="lg" placeholder="lg" /> |
| 83 | + <TelephoneInput width="xl" placeholder="xl" /> |
| 84 | + <TelephoneInput width="full" placeholder="full" /> |
| 85 | + </div> |
| 86 | + ), |
| 87 | +}; |
| 88 | + |
| 89 | +export const AllStates: Story = { |
| 90 | + name: 'All states', |
| 91 | + render: () => ( |
| 92 | + <div |
| 93 | + style={{ |
| 94 | + display: 'flex', |
| 95 | + flexDirection: 'column', |
| 96 | + gap: '1rem', |
| 97 | + maxWidth: '400px', |
| 98 | + }} |
| 99 | + > |
| 100 | + <div> |
| 101 | + <label |
| 102 | + style={{ |
| 103 | + display: 'block', |
| 104 | + marginBottom: '0.5rem', |
| 105 | + fontWeight: 'bold', |
| 106 | + }} |
| 107 | + > |
| 108 | + Default |
| 109 | + </label> |
| 110 | + <TelephoneInput placeholder="06 12345678" /> |
| 111 | + </div> |
| 112 | + <div> |
| 113 | + <label |
| 114 | + style={{ |
| 115 | + display: 'block', |
| 116 | + marginBottom: '0.5rem', |
| 117 | + fontWeight: 'bold', |
| 118 | + }} |
| 119 | + > |
| 120 | + With value |
| 121 | + </label> |
| 122 | + <TelephoneInput defaultValue="06 12345678" /> |
| 123 | + </div> |
| 124 | + <div> |
| 125 | + <label |
| 126 | + style={{ |
| 127 | + display: 'block', |
| 128 | + marginBottom: '0.5rem', |
| 129 | + fontWeight: 'bold', |
| 130 | + }} |
| 131 | + > |
| 132 | + Disabled |
| 133 | + </label> |
| 134 | + <TelephoneInput disabled value="06 12345678" /> |
| 135 | + </div> |
| 136 | + <div> |
| 137 | + <label |
| 138 | + style={{ |
| 139 | + display: 'block', |
| 140 | + marginBottom: '0.5rem', |
| 141 | + fontWeight: 'bold', |
| 142 | + }} |
| 143 | + > |
| 144 | + Read-only |
| 145 | + </label> |
| 146 | + <TelephoneInput readOnly value="06 12345678" /> |
| 147 | + </div> |
| 148 | + <div> |
| 149 | + <label |
| 150 | + style={{ |
| 151 | + display: 'block', |
| 152 | + marginBottom: '0.5rem', |
| 153 | + fontWeight: 'bold', |
| 154 | + }} |
| 155 | + > |
| 156 | + Invalid |
| 157 | + </label> |
| 158 | + <TelephoneInput invalid value="geen nummer" /> |
| 159 | + </div> |
| 160 | + </div> |
| 161 | + ), |
| 162 | +}; |
0 commit comments