/**
 * @license MIT
 * author: Cube Dev Team
 * @cube-dev/ui-kit v0.98.7
 * Released under the MIT license.
 */

import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Field, Form, Input, ResetButton, Space, SubmitButton, SubmitError, TextInput, } from '../index';
import { DialogFormApp } from './components/DialogFormApp';
import { DISABLE_BASE_ARGS } from './FormFieldArgs';
export default {
    title: 'Forms/Form',
    component: Form,
    argTypes: {
        ...DISABLE_BASE_ARGS,
    },
};
export const LoginForm = {
    // 1s of submitting
    render: (args) => (_jsxs(Form, { requiredMark: false, onSubmit: () => {
            return new Promise((resolve) => {
                setTimeout(resolve, 1000);
            });
        }, ...args, children: [_jsx(Field, { label: "Email", name: "email", rules: [
                    {
                        required: true,
                        message: 'E-mail required',
                    },
                    {
                        type: 'email',
                        message: 'Please enter a valid e-mail',
                    },
                ], children: _jsx(Input.Text, { type: "email" }) }), _jsx(Field, { label: "Password", name: "password", rules: [
                    {
                        required: true,
                        message: 'Password required',
                    },
                    {
                        min: 8,
                        message: 'The password must be at least 8 characters',
                    },
                ], children: _jsx(Input.Password, { type: "password" }) }), _jsx(SubmitError, {}), _jsxs(Space, { children: [_jsx(SubmitButton, { children: "Submit" }), _jsx(ResetButton, { children: "Reset" })] })] })),
    name: 'LoginForm',
};
export const SimpleValidation = {
    render: (args) => (_jsxs(Form, { onSubmit: (data) => {
            console.log('! Submit', data);
        }, ...args, children: [_jsx(Form.Item, { name: "test", label: "Test", rules: [
                    {
                        validator(rule, value) {
                            return value ? Promise.resolve() : Promise.reject('Required');
                        },
                    },
                ], children: _jsx(TextInput, {}) }), _jsxs(Space, { children: [_jsx(SubmitButton, { children: "Submit" }), _jsx(ResetButton, { children: "Reset" })] }), _jsx(Form.SubmitError, {})] })),
};
export const HorizontalLoginForm = {
    // 1s of submitting
    render: (args) => (_jsxs(Form, { orientation: "horizontal", labelPosition: "side", requiredMark: false, onSubmit: () => {
            return new Promise((resolve) => {
                setTimeout(resolve, 1000);
            });
        }, ...args, children: [_jsx(Field, { label: "Email", name: "email", rules: [
                    {
                        required: true,
                        message: 'E-mail required',
                    },
                    {
                        type: 'email',
                        message: 'Please enter a valid e-mail',
                    },
                ], children: _jsx(Input.Text, { type: "email", size: "small" }) }), _jsx(Field, { label: "Password", name: "password", rules: [
                    {
                        required: true,
                        message: 'Password required',
                    },
                    {
                        min: 8,
                        message: 'The password must be at least 8 characters',
                    },
                ], children: _jsx(Input.Password, { type: "password", size: "small" }) }), _jsx(SubmitButton, { size: "small", children: "Submit" })] })),
    name: 'HorizontalLoginForm',
};
export const DialogFormExample = {
    render: () => _jsx(DialogFormApp, {}),
    name: 'DialogFormApp',
};

        