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

form-group

v3.0.8

Published

## A vue component that resembles bootstraps FormGroup + formControl

Downloads

71

Readme

vue-form-group

A vue component input that emulates bootstrap's FormGroup formControl and is-valid

Demo

Screenshots

![alt text](./screenshot. PNG)

usage

npm install @fabrigeas/react-formg-roup

## register the component
src/main.ts
import 'form-group';

<template>
  <div id="app">
    {{name}}
      <FormGroup 
        :invalid="name.length < 3"
        :invalidFeedback="'Please fill this field!!'"
        :validFeedback="'looks good!'"
        :model.sync="name"
      />
  </div>
</template>

<script>
  import FormGroup from 'vue-FormGroup'

  export default {
    data: ()=>({
      name: ""
    }),
  }
  </script>ync="name"/>
</template>

Parameters

model {String} [required] - The only required property. Used for data binding

<template>
  {{name}}                  <-- Bound together
  <FormGroup  
    :model.sync="name"      <-- Use .sync for 2-way-binmding
  />
<template>
<script>
  export default {
    name: 'App',
    data: ()=>({
      name: ""
    }),

  }
  </script>
</script>

<!-- output -->
<div class="form-group">
  <input 
    type="text" 
    class="form-control is-valid" 
    id="4139c8f6-e922-4160-951d-bc94b6d67eb3" 
    model="some value"
  >
</div>

Update :model manually. This is useful when you want to perform addidional validations

<template>
  <FormGroup  
    :model="newPassword"
    @update:model="($event)=>validateNewPassword('newPassword', $event)"
  />
<template>
<script>
  export default {
    data: ()=>({
      newPassword: "",
      error{
        newPassword: false
      }
    }),
    
    methods: {
      validateNewPassword: function(name, value) {
        this[name] = value;

        const { newPassword, newPassword2, error } = this;
        error[name] = newPassword.length < 2;

      },
    },

  }
  </script>
</script>

<!-- output -->
<div class="form-group">
  <input 
    type="text" 
    class="form-control is-valid" 
    id="4139c8f6-e922-4160-951d-bc94b6d67eb3" 
    model="some value"
  >
</div>

type {String} [text, date, checkbox, select, textarea, ...]

text

  <FormGroup 
    :model.sync="Hello"
  />

  <!-- output -->
  <div class="form-group">
    <input 
      type="text" 
      class="form-control is-valid"
      id="4139c8f6-e922-4160-951d-bc94b6d67eb3" 
      model="Hello"
    >
  </div>

date (Datepicker)

  <FormGroup 
    type="date"
    :model.sync="23.09.1989"
  />

  <!-- output -->
  <div class="form-group">
    <input 
      type="date" 
      class="form-control is-valid"
      id="4139c8f6-e922-4160-951d-bc94b6d67eb3" 
      model="23-09.1989"
    >
  </div>

number

  <FormGroup 
    type="number"
    :model.sync="123"
  />

  <!-- output -->
  <div class="form-group">
    <input 
      type="date" 
      class="form-control is-valid"
      id="4139c8f6-e922-4160-951d-bc94b6d67eb3" 
      model="123"
    >
  </div>

checkbox

  <FormGroup 
    type="checkbox"
    :model.sync="male"
  />

  <!-- output -->
  <div class="form-group">
    <input 
      type="checkbox" 
      class="form-control is-valid"
      id="4139c8f6-e922-4160-951d-bc94b6d67eb3" 
      model="male"
    >
  </div>

textarea

  <FormGroup 
    type="textarea"
    :model.sync="Some text content"
  />

  <!-- output -->
  <div class="form-group">
    <textarea type="textarea" 
      class="form-control is-valid" 
      id="aed7eeed-4158-4e10-9e25-1d81b65e785c" 
      model="Some text content"></textarea>
  </div>

select

  <FormGroup 
    type="select"
    :model.sync="beta"
  >
    <option value="Alpha">Alpha</option>
    <option value="Beta">Beta</option>
    <option value="Charly">Charly</option>
  </select>

  <!-- output -->
  <div class="form-group">
    <select type="select" class="form-control is-valid" id="79674c60-2648-4a03-b597-2ecc2f932195" model="Beta">     
      <option value="Alpha">Alpha</option>
      <option value="Beta">Beta</option>
      <option value="Charly">Charly</option>
    </select>
  </div>

label {String} - The label for the input

<FormGroup 
  :label="'Name'"
  :model.sync="name"
/>

<!-- output -->
<div class="form-group">
  <label for="4139c8f6-e922-4160-951d-bc94b6d67eb3" class="form-label">Name:</label> 
  <input 
    type="text" 
    class="form-control is-valid" 
    id="4139c8f6-e922-4160-951d-bc94b6d67eb3" 
    model="some value"
  >
</div>

invalid {boolean} [default=false] - appends 'is-valid' or 'is-invalid' or input.className

invalid = true

<FormGroup 
  :model.sync="name" 
/>

<!-- output -->
<div class="form-group">
  <input 
    type="text" 
    class="form-control is-valid"  <-- replaces .is-invalid with .is-valid
    id="4139c8f6-e922-4160-951d-bc94b6d67eb3" 
    model="some value"
  >
</div>

invalid=true

<FormGroup 
  :model.sync="name" 
  :invalid="true
/>

<!-- output -->
<div class="form-group">
  <input 
    type="text" 
    class="form-control is-invalid" 
    id="4139c8f6-e922-4160-951d-bc94b6d67eb3" 
    model="some value"
  >
</div>

validFeedback {String} [optional] - The text to be displayed if input is valid

Must be combined with invalid=false

<FormGroup 
  :model.sync="name" 
  :invalid="name.length < 3"
  :validFeedback="'Perfect!'"
/>

<!-- output -->
<div class="form-group">
  <input 
    type="text" 
    class="form-control is-valid"
    id="4139c8f6-e922-4160-951d-bc94b6d67eb3" 
    model="some value"
  >
  <div class="valid-feedback">Perfect!</div>
</div>

invalidFeedback {String} [optional] - The text to be displayed if input is invalid

Must be combined with :invalid=true

<FormGroup 
  :model.sync="name" 
  :invalidFeedback="'Perfect!'"
  :invalid="name.length < 3"
/>

<!-- output -->
<div class="form-group">
  <input 
    type="text" 
    class="form-control is-valid"
    id="4139c8f6-e922-4160-951d-bc94b6d67eb3" 
    model="some value"
  >
  <div class="invalid-feedback">Perfect!</div>
</div>

css {Object} [optional] - css for the input only

<FormGroup 
  :model.sync="name" 
  :css = {
    "background" : "red !important",
    "padding": "1rem"
  }
/>

<!-- output -->
<div class="form-group">
  <input 
    type="text" 
    class="form-control is-valid"
    id="4139c8f6-e922-4160-951d-bc94b6d67eb3" 
    model="some value"
    style="background: red;"
  >
</div>

classes {String} - classList delimitted by spance or comma

<FormGroup 
  :model.sync="name" 
  :classes: "alpha, beta, charly delta"
/>

<!-- output -->
<div class="form-group">
  <input 
    type="text" 
    class="form-control is-valid alpha beta charly delta"
    id="4139c8f6-e922-4160-951d-bc94b6d67eb3" 
    model="some value"
  >
</div>

props {Object} - html properties and attributes

<FormGroup 
  :model.sync="name" 
  :props:{
      placeholder: "Placeholder text",
      autocomplete: "off",
      required: true,
      name:"Sample
    }
/>

<!-- output -->
<div class="form-group">
  <input 
    type="text" 
    class="form-control is-valid"
    id="4139c8f6-e922-4160-951d-bc94b6d67eb3" 
    model="some value"
    
    placeholder="Placeholder text" 
    autocomplete="off" 
    required="required" 
    name="Sample" 
  >
  
</div>

data {Object} - input.dataset

<FormGroup 
  :model.sync="name" 
  :data = {
    "name" : "fabrigeas",
    "user": "{name: 'fabrice', 'age': '30'}"
  }
/>

<!-- output -->
<div class="form-group">
  <input 
    type="text" 
    class="form-control is-valid"
    id="4139c8f6-e922-4160-951d-bc94b6d67eb3" 
    model="some value"
    data-name="fabrigeas"
    data-user="{&quot;name&quot;:&quot;fabrigeas&quot;,&quot;age&quot;:&quot;30&quot;}"
  >
</div>

events {Object} - events

Todo

  • Migrate to typescrip
  • Implement type=checkbox
  • Implement other event types
  • Reduce the size of css file by importing only required classes from bootstrap