0.1.33 • Published 3 years ago

awesome-quasar-form v0.1.33

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Awesome Quasar Form

Install

npm install awesome-quasar-form
# or
yarn add awesome-quasar-form

Connect to quasar

File : ~/boot/awesome.js

import { boot } from 'quasar/wrappers';
import { install as AwesomeQasarForm } from 'awesome-quasar-form';

export default boot(({ app }) => {
  app.use(AwesomeQasarForm);
});

/* OR
import { boot } from 'quasar/wrappers';
import AwesomeQasarForm, { AwesomeCodeEditor } from 'awesome-quasar-form';

export default boot(({ app }) => {
  app.component(AwesomeQasarForm.name, AwesomeQasarForm);
  app.component(AwesomeCodeEditor.name, AwesomeCodeEditor);
});
*/

Props

PropsTypeRequiredDefault
modelValueObjecttrue{}
isValidBoolean
structureArray

structure

KEYTYPeREQUIREDEXPLANE
typeString+field type string, textarea, number, integer, percent, boolean, select, color, lookup, code, json, array
keyString+field variable name
defaulttype, Function-field name
labelString-field name in form
propsObject-component properties

string (q-input)
{
    type: "string",
    key: "title",
    props: {
        placeholder: "Enter some title",
        autogrow: true
    }
}

// { title: "Some title" }
textarea (q-input)
{
    type: "textarea",
    key: "desc",
    props: {
        placeholder: "Enter some description",
        autogrow: true
    }
}
// { desc: "Some text" }
number (q-input)
{
    type: "number",
    key: "persent",
    default: 0.42,
    props: {
        min: 0,
        max: 1
    }
}
// { persent: 0.42 }
integer (q-input)
{
    type: "integer",
    key: "year",
    props: {
        min: 1980,
        max: 2042
    }
}
// { year: 1980 }
boolean (q-checkbox)
{
    type: "boolean",
    key: "checkbox",
    default: false
}
// { checkbox: false }
select (q-select)
{
    type: "select",
    key: "selected_number",
    props: {
        // options: ["1", "2"],
        options: [
            { _id: '1', name: "Foo" },
            { _id: '2', name: "Bar" }
        ],
        optionLabel: 'name', 
        optionValue: '_id'
    }
}
// { selected_number: "1" }
lookup (q-select)
{
    type: "lookup",
    key: "",
    props: {
        store: 'Users', // store module name
        optionLabel: '_id', 
        optionValue: '_id'
    }
}
// 
color (q-input)
{
    type: "color",
    key: ""
}
code (q-checkbox)
{
    type: "code",
    key: "code",
    props: {}
}

// { code: "() => { // js code }" }
json (awesome-code-editor)
{
    type: "json",
    key: "json_data",
    props: {}
}
// { json_data: '{ "foo": "bar" }' }
array (awesome-code-editor)
{
    type: "array",
    key: "names",
    props: {
        type: "string" // string | object
        // structure: [] // item structure (if type object)
    }
}
// { names: ['1', '2'] }
{
    type: "array",
    key: "names",
    props: {
        type: "object"
        structure: [
            { type: 'string', key: 'name' }
        ]
    }
}

// { names: [{ name: '1' }, { name: '2' }] }

Example

<template>
    <awesome-qusare-form
        v-model="data"
        :structure="structure"
    ></awesome-qusare-form>
</template>
<script>
import { ref } from 'vue';

export default {
    setup() {
        return {
            data: ref({}),
            structure: [
                {
                    key: "string", 
                    type: "string",

                    rules: [],
                    disable: false, 
                    props: { required: true } 
                },
                { key: "textarea", type: "textarea" },
                { key: "number", type: "number" },
                { key: "integer", type: "integer" },
                { key: "percent", type: "percent" },
                { key: "boolean", type: "boolean" },
                { key: "select", type: "select", options: ["1", "2", "3"] },
                { key: "color", type: "color" },
                { key: "code", type: "code" },
                { key: "json", type: "json" },
                {
                    key: "lookup",
                    type: "lookup",
                    store: "test",
                    optionLabel: "name",
                    optionValue: "id",
                },
            ]
        }
    }
}
</script>
0.1.32

3 years ago

0.1.33

3 years ago

0.1.30

3 years ago

0.1.31

3 years ago

0.1.29

3 years ago

0.1.24

3 years ago

0.1.25

3 years ago

0.1.26

3 years ago

0.1.21

3 years ago

0.1.22

3 years ago

0.1.23

3 years ago

0.1.20

3 years ago

0.1.15

3 years ago

0.1.16

3 years ago

0.1.17

3 years ago

0.1.18

3 years ago

0.1.19

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago