npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue3-form-lib

v1.0.3

Published

Form controls for VueJS that can be easily abstracted.

Downloads

3

Readme

Vue3 Form Library

Vue3 Form Library is a style agnostic component library, with multiple form input components that should cover all needs in a form using Vue3.

The purpose of creating a style agnostic component library is so that developers can write their own CSS in any pre-processor and this lib can easily apply to any project. You can target the built in classes and have forced consistency in your components. In certain cases, vue3 form lib enhances default HTML elements by defining HTML and classes for overriding the default HTML inputs like select, input[type="checkbox"] and input[type="file"], and supplies unique slots for adding vue templates.

Vue3 Form Library tries to use modern practices, by defining the built-in classes using BEM (Block, Element, Modifier) e.g. vue-form__button, this allows you to simply add modifiers like vue-form__button--lavendar to apply new styles. Vue3 Form Library also uses the most up to date practices in Vue3, by using the modern composition API.

Note: vue3-form-lib will only work in Vue3 + Typescript environments.

INSTALLATION

USAGE

Import

Independent Example

import registerVueFormLibrary from 'vue3-form-lib'

registerVueFormLibrary(app)

Project Example

import { createApp } from 'vue'
import App from './App.vue'

import registerVueFormLibrary from 'vue3-form-lib'

const app = createApp(App)

registerVueFormLibrary(app)

app.mount('#app')

Components

By default, all components are globally available after calling registerVueFormLibrary on your app so you do not need to import them. All components have default HTML styling until overriden.

FormButton

Props

disabled: Boolean - adds .vue-form__button--disabled to root element and disables click event

<FormButton @click="() => {

}">
  Click here
</FormButton>
button.vue-form__button {}

FormCheckbox

Props

disabled: Boolean - adds .vue-form__checkbox--disabled to root element and disables input

<FormCheckbox v-model="form.checkboxValue" />

<!-- FormCheckbox has a slot for adding custom html to the .vue-form__checkbox-inner, sibling to input[type="checkbox"] -->
<FormCheckbox v-model="form.checkboxValue" :disabled="true">
  <img src="tick.png" />
</FormCheckbox>
div.vue-form__checkbox {
  /* Here you can target the default checkbox, hide it, and the parent styling should still allow you to target it when adding custom styling. */
  input[type="checkbox"] {
    display: none;
  }
}
div.vue-form__checkbox-inner {}

FormFiles

Props

validator: Function - a function that fires on each file when added, takes a return value of true or false and emits an error event if any files return false, cancelling the input.

disabled: Boolean - adds .vue-form__files--disabled to root element and disables file input

multiple: Boolean - enables multiple files on the file input

<!-- The drop slot has custom functionality to take dropped files and apply them to v-model -->
<!-- The button slot has custom functionality to target the input, even if it is hidden, and open the browser file API for selecting a file. -->
<FormFiles v-model="form.filesValue">
  <template v-slot:drop>
    <div>
      Drop here
    </div>
  </template>
  <template v-slot:button>
    <button>
      Upload file
    </button>
  </template>
</FormFiles>
div.vue-form__files {
  input[type="file"] {}
}
/* vue-form__file-drop and vue-form__file-button are custom parent divs of the template/slots */
div.vue-form__file-drop {}
div.vue-form__file-button {}

FormInput

Props

disabled: Boolean - disables input

type: String - applies to input[type]

placeholder: String - applies to input[placeholder]

<FormInput v-model="form.inputValue" />
input.vue-form__input {}
input.vue-form__input[disabled] {}

FormRadio

Props

values: Array - an array of values to display as checkboxes

disabled: Boolean - adds vue-form__radio--disabled to root element and disables all checkboxes

<!-- FormRadio contains three custom slots as seen below -->
<!-- <slot :name="`option-before-${String(index)}`"></slot> -->
<!-- <slot :name="`checkbox-inner-${String(index)}`"></slot> -->
<!-- <slot :name="`option-after-${String(index)}`"></slot> -->
<!-- These slots must match their dynamic names exactly but can be used to apply icons to the checkbox-inner HTML or to add text to before or after each radio value. -->
<FormRadio v-model="form.radioValue" :values="arrayOfValues">
  <template v-for="(value, index) in arrayOfValues" v-slot:[`option-before-${index}`]>{{ radioValue }}</template>
</FormRadio>
div.vue-form__radio {}
div.vue-form__radio-option {}
/* This doubles up with the vue-form__checkbox and vue-form__checkbox-inner so both use the same styling. */
div.vue-form__checkbox {
  input[type="checkbox"] {}
}
div.vue-form__checkbox-inner {}

FormSelect

Props

disabled: Boolean - adds vue-form__select--disabled to root element and disables select element

<!-- FormSelect has 3 slots. A default slot for options and after/before slots to add things like custom arrows.-->
<FormSelect v-model="form.selectValue">
  <template v-slot:before>
    <div></div>
  </template>
  <option>
    Option 1
  </option>
  <option>
    Option 2
  </option>
  <template v-slot:after>
    <div></div>
  </template>
</FormButton>
div.vue-form__select {
  select {}
}