import React, { useState, useRef } from 'react';
import { SelectField, SelectFieldComponentProps } from '@lendi/ui/SelectField';
import { Button } from '@lendi/ui/Button';
import { Spacer } from '@lendi/ui/Layout';
const defaultArgs = {
options: [
{ value: 'thing-1', label: 'Thing 1' },
{ value: 'thing-2', label: 'Thing 2' },
{ value: 'thing-3', label: 'Thing 3' },
],
};
export const Interactive = (args: SelectFieldComponentProps) => {
return ;
};
Interactive.args = {
...defaultArgs,
label: 'Label text',
};
export const Headers = (args) => (
);
export const Errors = (args) => (
);
Errors.args = { ...defaultArgs };
export const AutoComplete = () => (
);
export const Labels = (args) => (
);
Labels.args = { ...defaultArgs };
export const Controlled = (args) => {
const [value, setValue] = useState('');
const handleChange = (e) => {
console.log(e.target.value);
setValue(e.target.value);
};
return ;
};
Controlled.args = {
...defaultArgs,
label: 'Label',
placeholder: 'Placeholder text',
helpText: 'Help text',
options: [
{
header: 'A header',
options: [
{ label: 'Option 1', value: 'opt-1' },
{ label: 'Option 2', value: 'opt-2' },
],
},
{ label: 'Option 3', value: 'opt-3' },
{ label: 'Option 4', value: 'opt-4' },
],
};
export const Uncontrolled = (args) => {
const selectRef = useRef(null);
const showVal = () => {
console.log(selectRef.current.value);
};
return (
);
};
Uncontrolled.args = { ...defaultArgs };
export const Widths = (args) => (
);
Widths.args = { ...defaultArgs };