1.11.4 • Published 4 years ago

@tillhub/vue-search-filter v1.11.4

Weekly downloads
13
License
MIT
Repository
github
Last release
4 years ago

@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

AttributeTypeRequiredExampleDefaultDescription
widthnumberno500460sets fixed width of component in pixels, minimum is 350
localestringno"de""en"Currently only German and English is supported. Only 'de' and 'en '
inputPlaceholderstringno"Search in products""Search"Sets the placeholder text in the input field
searchButtonTextstringno"Submit""Search"Sets a custom text in the blue submitting button
resetButtonTextstringno"Reset""Cancel"Sets a custom text in the reset button

Events

EventDescriptionParams
submittriggers when the user clicks on "search" buttonfilters
resettriggers when the user clicks on the "reset" button--
close-dropwdowntriggers 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.

NameTypeExampleDescription
inputobject{ 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).
addTagfunction({ 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

1.11.4

4 years ago

1.10.0

5 years ago

1.9.0

5 years ago

1.8.0

5 years ago

1.7.1

5 years ago

1.7.0

5 years ago

1.6.0

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago