0.4.1 โ€ข Published 1 year ago

smart-tagz v0.4.1

Weekly downloads
24
License
MIT
Repository
github
Last release
1 year ago

Build Status Codacy Badge DeepScan grade Language grade: JavaScript Snyk Vulnerabilities for GitHub Repo Depfu

Edit smart-tagz

  • โšก Autosuggest with support for keyboard selection.
  • โœ๏ธ Edit the tags inline by double clicking them.
  • ๐Ÿท๏ธ Paste strings with delimiters of your choice and the component will create the tags for you.
  • ๐Ÿ—‘๏ธ Quickly delete the tags with a visual confirmation before removing a tag.
  • ๐Ÿงน Quickly clear all tags with quick-delete mode.
  • ๐Ÿ”’ ย Lock the component using the readonly mode.
  • โœ‹ ย Restrict the number of tags and Handle duplicates gracefully.
  • ๐ŸŒˆย Customize the colors.

Table of Contents

โšก Installation

yarn install smart-tagz

๐Ÿš€ Getting Started

smart-tagz has some great defaults to get you started quickly. Please check the props list for all options.

<template>
  <smart-tagz
    autosuggest
    editable
    inputPlaceholder="Select Countries ..."
    :sources="sources"
    :allowPaste="{delimiter: ','}"
    :allowDuplicates="false"
    :maxTags="20"
    :defaultTags="['United Kingdom', 'Uruguay', 'Uzbekistan']"
  />
</template>

<script>
import { SmartTagz } from "smart-tagz";
import "smart-tagz/dist/smart-tagz.css";

import { defineComponent } from "vue";

export default defineComponent({
  name: "Basic",
  components: {
    SmartTagz,
  }
});
</script>

๐Ÿฌ Demos

Head to our demo page for examples showcasing all the features.

https://smart-tagz.vercel.app/

Props

PropTypeDescriptionDefault
defaultTagsArrayinitialize with a default set of tags[]
widthStringwidth of the container100%
autosuggestBooleanEnables the autosuggest feature. you also need to set the sources for the autosuggest to work.false
sourcesArrayWorks as the datasource for the autosuggest feature[]
allowPaste{ delimiter: String }Parses the pasted string based on the passed delimiter and creates tags automatically{delimiter: ","}
editableBooleanmakes the tags editablefalse
allowDuplicatesBooleanallows/disallows duplicate tag entries while pasted or entered manually.true
maxTagsNumbersets the Maximum number of tags10
inputPlaceholderStringPlaceholder for the input box."Enter tag..."
readOnlyBooleanMakes the whole component readOnly. ideal for display only purposes.false
quick-deleteBooleanWhen enabled all the tags can be cleared by CTRL + A, DELfalse
on-changedFunctioncallback that gets called when a new tag is added or an existing tag is deletedfalse

Default Tags

We can initialize smart-tagz with some default tags. This setting will mostly be used along with the readonly prop to create tags for display only purposes.

<smart-tagz :default-tags="['United Kingdom', 'Uruguay', 'Uzbekistan']" />

Duplicates

You can decide how to manage duplicate tags by either allowing or disallowing them completely. When set to false no duplicate values are allowed.

<smart-tagz :allow-duplicates="false" />

Auto Suggest

Whe set to true, the autosuggest prop suggests values in a dropdown. You also need to set the sources prop for this to work. The sources prop can be an Array of strings.

 <smart-tagz autosuggest :sources="['India', 'Brazil', 'China', 'United Kingdom']" />

Max Tags

The component can also be configured to accept the Maximum number of tags that can be created. Once the threshold is reached, the input will be hidden from the user.

Here we restrict the tags to 3

<smart-tagz :max-tags="3" />

Paste

The component can parse strings and automatically create tags for you. The default delimiter is "," but you can override this setting by manually setting the delimiter option.

<smart-tagz :allow-paste="{delimiter: ';'}" />

Editable Tags

The Tags are not editable by default, but you can change this setting with the editable prop. Simply double click a tag, make the changes and hit enter to save.

<smart-tagz editable />

Readonly Tags

You can lock the component with readonly mode. All interactions are disabled in read-only mode.

<smart-tagz read-only />

Theme

The components color scheme can be customized by passing a custom theme prop.

  <smart-tagz
    :theme="{
      primary: '#545454',
      background: '#bdbdbd',
      tagTextColor: '#fff',
    }"
  />

Custom Class names

If you are looking for more control in terms of customizing the style of the tags, you can make use of the classNames prop to apply custom classes to the different elements within the component.

<smart-tagz
  input-placeholder="Select Countries ..."
  :class-names="{
    wrapper: 'tags_wrapper_custom',
    tag_name: 'tag_name_custom',
    tag_container: 'tag_container_custom',
    tag_close_btn: 'tag_close_btn_custom',
  }"
  :default-tags="[
    'United Kingdom',
    'Uruguay',
    'Uzbekistan',
    'Venezuela'
  ]"
/>

๐Ÿ“ฆ Build Setup

# install dependencies
yarn install

# start dev
yarn run dev

# package lib
npm run rollup

# run css linting
yarn run lint:css

๐Ÿ”จ Contributing

  1. Fork it ( https://github.com/prabhuignoto/smart-tagz/fork )
  2. Create your feature branch (git checkout -b new-feature)
  3. Commit your changes (git commit -am 'Add feature')
  4. Push to the branch (git push origin new-feature)
  5. Create a new Pull Request

Notes

The project uses vite instead of @vue/cli. I choose vite for speed and i also believe vite will be the future.

Meta

Prabhu Murthy โ€“ @prabhumurthy2 โ€“ prabhu.m.murthy@gmail.com

Distributed under the MIT license. See LICENSE for more information.

https://github.com/prabhuingoto/

0.4.1

1 year ago

0.4.0

1 year ago

0.3.2

2 years ago

0.3.0

2 years ago

0.3.1

2 years ago

0.2.0

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago