1
0
mirror of synced 2024-11-24 14:26:03 +03:00
Go to file
Kruglov Kirill b5961c52eb
Merge pull request #29 from cmath10/0.6.0-experimental
v0.6.0 Form state management refactoring, release automation
2021-06-17 17:12:23 +03:00
.github chore: github-actions testing pipeline 2021-06-14 14:02:10 +03:00
build chore: Removed unused dependency 2021-06-14 14:02:10 +03:00
dist 0.5.1 2020-11-17 09:36:13 +03:00
src chore: Removed unused type declaration 2021-06-15 11:14:04 +03:00
storybook refactor: State management logic & tests 2021-06-14 14:02:10 +03:00
test refactor: Deep cloning of state, deep equal checker 2021-06-14 14:02:10 +03:00
.commitlintrc.json chore: Release automation preparations 2021-06-14 14:02:10 +03:00
.editorconfig Changed intend_size 2020-05-21 14:30:55 +03:00
.eslintignore chore: Added storybook, removed vue-i18n (was not in use) 2020-10-19 13:45:28 +03:00
.eslintrc.js chore: Updated eslint rules 2021-06-14 14:02:10 +03:00
.gitignore docs: Added storybook for case of array of fields 2020-11-02 11:54:50 +03:00
.npmignore chore: Release automation preparations 2021-06-14 14:02:10 +03:00
.travis.yml Updates build to use node 11 2019-11-01 14:35:06 -04:00
.versionrc.json chore: Release automation preparations 2021-06-14 14:02:10 +03:00
babel.config.js style: Fixed style of babel.config.js 2020-10-19 13:45:18 +03:00
docker-compose.yml chore: github-actions testing pipeline 2021-06-14 14:02:10 +03:00
LICENSE.txt Library renamed to formulario 2020-05-22 14:22:56 +03:00
Makefile chore: Docker configuration for dev 2020-10-19 13:45:17 +03:00
package.json chore: Release automation preparations 2021-06-14 14:02:10 +03:00
README.md docs: README.md clarification 2021-06-14 14:02:10 +03:00
tsconfig.json chore: Build config fixes, modules paths correction 2020-10-19 13:45:15 +03:00
yarn.lock Merge pull request #29 from cmath10/0.6.0-experimental 2021-06-17 17:12:23 +03:00

What is Vue Formulario?

Vue Formulario is a library, inspired by Vue Formulate, that handles the core logic for working with forms and gives full control on the form presentation.

Examples

Every form control have to rendered inside FormularioField component. This component provides id and context in v-slot props. Control should use context.model as v-model and context.runValidation as handler for blur event (it is necessary for validation when property validationBehavior is demand). Errors list for a field can be accessed through context.allErrors.

The example below creates the authorization form from data:

{
    "username": "",
    "password": "",
    "options": {
        "anonymous": false,
        "tags": ["test"]
    }
}
<FormularioForm
    v-model="formData"
    name="formName"
>
    <FormularioField
        v-slot="{ context }"
        name="username"
        validation="required|email"
        validation-behavior="live"
    >
        <input
            v-model="context.model"
            type="text"
            @blur="context.runValidation"
        >
        <div v-if="context.allErrors.length > 0">
            <span
                v-for="(error, index) in context.allErrors"
                :key="index"
            >
                {{ error }}
            </span>
        </div>
    </FormularioField>

    <FormularioField
        v-slot="{ context }"
        name="password"
        validation="required|min:4,length"
    >
        <input
            v-model="context.model"
            type="password"
        >
    </FormularioField>

    <FormularioFieldGroup name="options">
        <FormularioField
            v-slot="{ context }"
            name="anonymous"
        >
            <div>
                <input
                    id="options-anonymous"
                    v-model="context.model"
                    type="checkbox"
                >
                <label for="options-anonymous">As anonymous</label>
            </div>
        </FormularioField>
    </FormularioFieldGroup>

    <FormularioField
        v-slot="{ context }"
        name="options.tags[0]"
    >
        <input
            v-model="context.model"
            type="text"
        >
    </FormularioField>
</FormularioForm>

License

MIT

Copyright (c) 2020-present, RetailDriver LLC
Copyright (c) 2020-present, Braid LLC