import * as React from 'react' import type { StoryFn, Meta } from '@storybook/react-webpack5' import { Input, Textarea, FormSection, Layout, Form, RadioGroup, Radio, Checkbox, CheckboxGroup, } from '..' import Footer from '../docs/footer' import { useForm } from '@mantine/form' import { ButtonPrimary, ButtonEmpty } from '@planview/pv-uikit' import Combobox from '../combobox' export default { title: 'pv-form/Examples', tags: ['autodocs'], parameters: { docs: { description: { component: `An example combining the layout- and form-components from \`pv-form\` and managing form state using \`useForm\` from [mantine](https://mantine.dev/form/use-form/)`, }, }, controls: { disabled: true, hideNoControlsWarning: true, }, }, } satisfies Meta export const Default: StoryFn = () => { const form = useForm({ initialValues: { sample: 'Thanks', other: '', yet: '', another: '', input: '', field: '', weekdays: 'mon', email: '', teams: { barcelona: false, madrid1: false, madrid2: false, aik: false, }, language: { label: 'English', value: 'en' }, }, validateInputOnBlur: true, validate: { sample: (val) => (!val ? 'Required' : null), other: (val) => (val === 'error' ? 'Something is wrong' : null), email: (value) => /^\S+@\S+$/.test(value) ? null : 'Invalid email', teams: { aik: (val: boolean) => (val ? 'AIK is not allowed' : null), }, language: (value) => value.value === 'nl' ? 'Language is not supported' : null, weekdays: (val) => val === 'tue' ? 'Wrong day, please select a different one!' : null, }, }) return (
{ event.preventDefault() event.stopPropagation() console.log(form.values) }} >