Code Monkey home page Code Monkey logo

vue-search-filter's Introduction

@tillhub/vue-search-filter CircleCI

Vue search input with dropdown for more filters

Install

npm install --save @tillhub/vue-search-filter

Usage

Please see example folder for complete code example. Note, that the css has to be imported separately. This library assumes that element-ui is being used by the caller.

To see the example in action:

npm run serve
<template>
  <th-search-filter
    @submit="handleSubmit"
    @reset="handleReset"
    :width="500"
    locale="de"
    resetButtonText="Reset now"
    input-placeholder="Search in customer names"
  >
    <template slot="dropdown-content" slot-scope="{input, addTag}">
      <branch-filter :input="input" :add-tag="addTag"/>
      <status-filter :input="input" :add-tag="addTag"/>
      <active-switch :input="input" :add-tag="addTag"/>
      <date-picker :input="input" :add-tag="addTag"/>
    </template>
  </th-search-filter>
</template>

<script>
import ThSearchFilter from '../src/index.vue'
import BranchFilter from './BranchFilter.vue'
import StatusFilter from './StatusFilter.vue'
import ActiveSwitch from './ActiveSwitch.vue'
import DatePicker from './DatePicker.vue'

export default {
  components: {
    ThSearchFilter,
    BranchFilter,
    StatusFilter,
    ActiveSwitch,
    DatePicker
  },
  methods: {
    handleSubmit (result) {
      console.log('submit', result)
    },
    handleReset () {
      console.log('reset')
    }
  }
}

</script>

Attributes

Attribute Type Required Example Default Description
width number no 500 460 sets fixed width of component in pixels, minimum is 350
locale string no "de" "en" Currently only German and English is supported. Only 'de' and 'en '
inputPlaceholder string no "Search in products" "Search" Sets the placeholder text in the input field
searchButtonText string no "Submit" "Search" Sets a custom text in the blue submitting button
resetButtonText string no "Reset" "Cancel" Sets a custom text in the reset button

Events

Event Description Params
submit triggers when the user clicks on "search" button filters
reset triggers when the user clicks on the "reset" button --
close-dropwdown triggers when the user closes the dropwdown --

Slot

One named slot it provided: "dropwdown-content". It is highly advised to refer to the example folder to see how this slot is used. Understanding the parent-child communication is crucial as the dropdown content and input content are closely linked.

Name Type Example Description
input object { key1: { label: "product name", value: "product uuid"}, key2: { label: "branch name", value: "branch uuid"} } this is an object that depicts the current state of the tags in the input field,
on every change they are passed to the slot so the consumer can update the slot children accordingly.
The key name is determined by the user, when it is being passed in the "addTag" method (see below).
addTag function ({ name, value, label }) => {} This method communicates the changes in the slot children to the parent.
It adds tags to the parent input field.E.g. it can be called on every change in the child.
The method expects to be called with an object with at least the "name" prop.
If "label" is falsey, it will default to "value".

License

MIT © qtotuan

vue-search-filter's People

Contributors

qtotuan avatar eljefedelrodeodeljefe avatar semantic-release-bot avatar jmy-kellogg avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.