3.5.6 • Published 4 months ago

@tvaliasek/vue-form-inputs v3.5.6

Weekly downloads
1
License
MIT
Repository
-
Last release
4 months ago

Customized bootstrap vue form inputs for BS 5 and Vue 3

Wrapper components over most commonly used bootstrap vue form input components, with support for vuelidate, vue i18n and vue 3 datepicker. Input plugin can automatically register required components from bootstrap-vue-next.

Main goal is to simplify common bootstrap form design in my own projects.

Install

npm install @tvaliasek/vue-form-inputs

# peer dependencies
npm install bootstrap
npm install bootstrap-vue-next
# for datepicker
npm install @vuepic/vue-datepicker
import { createApp } from 'vue'

import { FormInputsPlugin } from '@tvaliasek/vue-form-inputs'
import '@tvaliasek/vue-form-inputs/dist/vue-form-inputs.css'

import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue-next/dist/bootstrap-vue-next.css'

const app = createApp(App)

app.use(FormInputsPlugin({ includeBootstrapNextComponents: true }))

// or import individual components

/*
    FormInput
    FormInputDatePicker
    FormInputTextarea
    FormInputSelect
    FormInputRadioGroup
    FormInputCheckbox
    FormInputCheckboxGroup
    FormInputFile
*/

Usage, props and slots

Basic usage example:

<template>
    <!-- Common text input with validation -->
    <FormInput
        id="htmlId"
        label="Common text input"
        :validation="validations.example"
        v-model="example"
    />
</template>

<script setup>
import useVuelidate from '@vuelidate/core'
import { ref, computed } from 'vue'
import { required } from '@vuelidate/validators'

const example = ref('')
const validations = useVuelidate(computed(() => ({ example: { required } })), { example })
</script>

Props

Common props for all components

proptyperequireddefaultdescription
labelstringfalseempty stringInput label text
sizestringfalseundefinedSize of input - sm, lg or not set
validationMessagesobjectfalseempty objectkey - value pairs for validation messages
validationobjectfalseempty objectvuelidate validation entry instance
disabledbooleanfalsefalseInput html disabled attribute
modelValueundefinedfalseundefinedv-model value
hintstringfalseundefinedhint text for input displayed under form input
idstringfalseundefinedInput html id attribute
readOnlybooleanfalsefalsetoggle for readonly attribute

Text

proptyperequireddefaultdescription
typestringfalse'text'Input html attribute type
placeholderstringfalseundefinedinput placeholder html attribute
formatterfunctionfalseundefinedfunction to apply on value as formatter
renderAsGroupbooleanfalsefalsetoggle for input group rendering, use slots default / append and prepend
lazyFormatterbooleanfalsetruecontrol behaviour of formatter function

Textarea

proptyperequireddefaultdescription
placeholderstringfalseundefinedinput placeholder html attribute
formatterfunctionfalseundefinedfunction to apply on value as formatter
lazyFormatterbooleanfalsetruecontrol behaviour of formatter function

Select

proptyperequireddefaultdescription
optionsarraytrueundefined{ value: 'someValue', text: 'Some value' }
multibooleanfalsefalsetoggle for multiselect rendering
selectSizenumberfalseundefinedset number of rows for multiselect
placeholderstringfalseundefinedinput placeholder html attribute
renderAsGroupbooleanfalsefalsetoggle for input group rendering, use slots default / append and prepend

Radio group, Checkbox group

proptyperequireddefaultdescription
optionsarraytrueundefined{ value: 'someValue', text: 'Some value' }
stackedbooleanfalsetruetoggle to render inputs side by side

Checkbox

proptyperequireddefaultdescription
renderAsSwitchbooleanfalsefalsetoggle to render input as switch

Datepicker

Datepicker is wrapped @vuepic/vue-datepicker

proptyperequireddefaultdescription
localestringfalsecs-CZlanguage code for Intl
minDateDatefalseundefinedminimal date for calendar
maxDateDatefalseundefinedmaximal date for calendar
enableTimebooleanfalsefalsetoggle for date and time selection
ignoreTimeValidationbooleanfalsetruevalidate only date part
dateFormatfunctionfalseundefinedcustom date formatter function
placeholderstringfalseundefinedinput placeholder html attribute
enforceUtcbooleanfalseundefinedenforces UTC format
defaultTime{ hours: string | number, minutes: string | number, seconds: string | number }falseundefinedsets default time

File

proptyperequireddefaultdescription
multiplebooleanfalsefalseset to true to enable multiple file selection
acceptstring or string[]false[]define list of extensions or mime type patterns allowed for selection, model value is automatically filtered using these patterns

i18n

If vue i18n is detected, please add these translations:

{
    "cs": {
        "vueFormInputs": {
            "feedback": {
                "required": "Toto pole je nutné vyplnit.",
                "minLength": "Hodnota musí být minimálně {minLength} znaků dlouhá.",
                "maxLength": "Hodnota musí být maximálně {maxLength} znaků dlouhá.",
                "minValue": "Hodnota musí být minimálně {minValue}.",
                "maxValue": "Hodnota musí být maximálně {maxValue}.",
                "between": "Hodnota musí být mezi {betweenMin} a {betweenMax}.",
                "alpha": "Jsou povoleny pouze písmena.",
                "alphaNum": "Jsou povoleny pouze písmena a čísla.",
                "numeric": "Jsou povoleny pouze čísla.",
                "integer": "Jsou povolena pouze celá čísla.",
                "decimal": "Jsou povolena pouze desetinná čísla.",
                "email": "Chybný formát emailové adresy.",
                "ipAddress": "Chybný formát IP adresy.",
                "macAddress": "Chybný formát MAC adresy.",
                "sameAs": "Hodnota není shodná.",
                "url": "Chybný formát URL adresy.",
                "validatedEmail": "Nefunkční nebo chybná emailová adresa.",
                "invalidValue": "Chybně vyplněná hodnota."
            }
        }
    },
    "en": {
        "vueFormInputs": {
            "feedback": {
                "required": "This field must be filled.",
                "minLength": "The value must be at least {minLength} characters long.",
                "maxLength": "The value must be at most {maxLength} characters long.",
                "minValue": "The value must be at least {minValue}.",
                "maxValue": "The value must be at most {maxValue}.",
                "between": "The value must be between {betweenMin} and {betweenMax}.",
                "alpha": "Only letters are allowed.",
                "alphaNum": "Only letters and numbers are allowed.",
                "numeric": "Only numbers are allowed.",
                "integer": "Only whole numbers are allowed.",
                "decimal": "Only decimal numbers are allowed.",
                "email": "Incorrect email address format.",
                "ipAddress": "Incorrect IP address format.",
                "macAddress": "Incorrect MAC address format.",
                "sameAs": "The values are not identical.",
                "url": "Incorrect URL address format.",
                "validatedEmail": "Broken or incorrect email address.",
                "invalidValue": "Incorrectly filled value."
            }
        }
    }
}
3.5.6

4 months ago

3.5.5

10 months ago

3.5.4

10 months ago

3.5.3

10 months ago

3.5.2

11 months ago

3.5.1

11 months ago

3.5.0

11 months ago

3.3.4

11 months ago

3.3.3

12 months ago

3.3.2

1 year ago

3.3.1

1 year ago

3.2.2

1 year ago

3.3.0

1 year ago

3.2.1

1 year ago

3.2.0

1 year ago

3.1.1

1 year ago

3.0.2

1 year ago

3.1.0

1 year ago

3.2.3

1 year ago

3.0.0

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.1.18

1 year ago

1.1.16

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.12

2 years ago

1.1.13

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.0

3 years ago