Git Product home page Git Product logo

vue-search-select's Introduction

vue-search-select

A Vue.js search select component with NO dependencies.

Version 3

  • Support Vue.js 3.x

export files

There are three file.

  • VueSearchSelect.js
  • VueSearchSelect.umd.js
  • VueSearchSelect.css

Components

  • ModelSelect (from v2.3.8)
    • value set through v-model
    • value can be string, number, boolean and object
      • If you v-model type is string, onInput set by string. (Not option object)
  • ModelListSelect (from v2.3.8)
    • value set through v-model
    • Can pass custom list and customize display text to Component
    • Wrap ModelSelect component
  • MultiSelect
    • search select for multiple select
  • MultiListSelect
    • ListSelect for MultiSelect

Version2's BasicSelect, ListSelect components are removed.

Styles

import "vue-search-select/dist/VueSearchSelect.css"

Semantic-ui-css compatible html and css classes used.

If you already use semantic-ui(or fomantic-ui) VueSearchSelect.css import is unnecessary. If you want use vue-search-select without semantic-ui-css, import VueSearchSelect.css.

Release Notes

https://github.com/moreta/vue-search-select/releases

Demo

https://vue-search-select.netlify.com

Usage

Install

npm install --save vue-search-select
yarn add vue-search-select
pnpm add vue-search-select

Props

Component Name Type Default Description
ModelSelect options Array option list
isError Boolean false error style
isDisabled Boolean false disable component
placeholder String ''
filterPredicate String new RegExp(inputText, 'i')
customAttr Function () => '' Add custom html attribute
name String input form name attribute
id String id attribute
searchchange Event event triggered on search change
blur Event event triggered on input blur
ModelListSelect list Array option list
optionValue String value key
optionText String text key
customText Function custom text function
optionDisabled String false disabled key
isError Boolean false error style
isDisabled Boolean false disable component
placeholder String ''
filterPredicate String new RegExp(inputText, 'i')
name String input form name attribute
id String id attribute
searchchange Event event triggered on search change
blur Event event triggered on input blur
MultiSelect options Array option list
selectedOptions Array default option list
isError Boolean false error style
isDisabled Boolean false disable component
placeholder String ''
filterPredicate String new RegExp(inputText, 'i')
customAttr Function () => '' Add custom html attribute
hideSelectedOptions Boolean false Hide Option list that item selected
name String input form name attribute
id String id attribute
searchchange Event event triggered on search change
blur Event event triggered on input blur
select Event event triggered when item selected
MultiListSelect list Array option list
optionValue String value key
optionText String text key
customText Function custom text function
optionDisabled String false disabled key
selectedItems Array default option(raw object)
isError String false error style
isDisabled Boolean false disable component
placeholder String ''
filterPredicate String new RegExp(inputText, 'i')
name String input form name attribute
id String id attribute
searchchange Event event triggered on search change
blur Event event triggered on input blur
select Event event triggered when item selected

Run examples

pnpm run build
pnpm run dev:docs

vue-search-select's People

Contributors

ahmad-reza619 avatar amal-qb avatar avaromatias avatar beeches avatar brakiojj avatar citizen-thayne avatar dependabot[bot] avatar dmpotapenko avatar eder87rh avatar impranavkale avatar javiercbk avatar lerte avatar lraphael avatar madeitbelgium avatar moreta avatar puzon avatar qburst-harikrishnanp avatar sett4 avatar tgbv avatar tienne-b avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-search-select's Issues

Can you add custom filtering rules?

In BasicSelect.vue, the following methods:
filteredOptions () {
if (this.searchText) {
return this.options.filter(option => {
return option.text.match(new RegExp(this.searchText, 'i'))
})
} else {
return this.options
}
}

Would you like to open this method to make your own filtering rules?

Error with Nuxt: "Cannot read property 'middleware' of undefined"

When putting this in a Nuxt-based project, I get "Cannot read property 'middleware' of undefined", which usually means that the component is doing something on the server side that it can't do.

Does anyone know of a workaround for this?

To recreate, create a project like this:

npx create-nuxt-app my-project

And add the component exactly as the example shows. When loading the page, the above message appears.

Supply value as a string rather than an object

I'd like to be able to use :selected-option="value" where value is just the value for the select, rather than an object with the text + value.

Currently I have to store both the text and value in a cookie in order to correctly pre-fill the select on next page load. This is frustrating when text for that value could change over time and would therefore fall out of sync with my cookie.

Optgroup

It would be nice to have option groups available, or maybe I just could not find it in the documentation.

Split searchText & selectedOption.text

Semantic UI's Search Selection using <div class="text"></div> for selected contents.

vue-search-select don't.
After first select then click input once more vue-search-select do not show options.
Because searchText alread placed with full option text.

This should be fix.

Required setup for the component

What is the required setup for the component to behave like the one in the demo?

By "required setup" I mean, what dependencies does the component require? Do I have to use Semantic UI, or any other libraries? I've tried using the component in a project, and it is not behaving the way it does in the demo. Specifically, when I choose an option the menu disappears and also there's no delete icon. I've replicated the demo here. I'm guessing this probably has to do with Semantic UI or something like that.

Thanks!

Selecting an option programmatically has a bug.

I have a select component.
I opened it and clicked on the third option - "Need Confirmation"
I then at some time reseted to the first option with the following code:
this.item = this.options[0]
It seemed to work OK until I pressed on the select again and the third option is highlighted instead of the first one.

opera snapshot_2018-03-29_164327_localhost

You can see as well that the text in the text box shows that it is indeed fixated on the first option but still highlighting the third.

Remove triggerValue prop

If parent component mutate value of triggerValue, we got this message on Vue2.0

 Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "value"

Using triggerValue prop for reseting value is not good.
"triggerValue" prop it should be remove and research other approch

Placeholder props not working

version: 2.4.0
Why placeholder props not working?

<model-select :options = "sessions" v-model = "searchForm.sessionId"
			title = "Select session" style = "width: 100%; display: inline-block"
			placeholder="select item">
</model-select >

Browser image where select model used:

image

@select for ModelListSelect

Is anyone having problems getting this to work? I did a simple function to print to console, but it doesn't work.

help

hello, How can I add the up and down arrows, and esc to close menu

Add http request ??

thanks

demo not working ( _h is not defined)

copy / pasted from the example.
on vue v2.1.6

here is the console output (shortened)

[Vue warn]: Error when rendering component <basic-select>: 
vue.runtime.common.js?d43f:2961 Uncaught ReferenceError: _h is not defined

backend.js:1 [vue-devtools] Ready. Detected Vue v2.1.6

using this if it matters
https://github.com/egoist/vuepack

Allow css customizations on custom properties (Feature Request)

An item should have a text and a value, but it could have other custom properties without interfering with the library's normal behavior.

I want to allow css customizations on some custom property in order to change the color (or any) css property.

I've created a PR that addresses this feature.

Why does not work with gulp?

Hi @moreta

I have a problem when I'm loading your package.
I'm using gulp, browserify and babelify.

Any idea?

Error: Cannot find module '!!./../../../node_modules/css-loader/index.js!./../../../node_modules/vue-loader/lib/style-rewriter.js?id=data-v-3bdee3a6!./../../../node_modules/vue-loader/lib/selector.js?type=styles&index=1!./ModelSelect.vue' from '/var/www/withpassion/docker-projects/wesele123.local/html/node_modules/vue-search-select/publish'

set name for input

hello how i can set name for input ? i need use vue-search-select in post method form

isDisabled

Hi, it would be nice to be able to disable the component using a prop, like the :isError

Automatically change the width when selecting an option

When selecting an option, the width of the select is automatically stretched making my modal in view for telephones disengage a little. This does not happen with any other component and also the options that I select are very short texts.

image

As you can see there has already stretched the width of the entire modal because of the select

Object as a default value

options2: [
         { value: '1', text: 'aa' + ' - ' + '1' },
         { value: '2', text: 'ab' + ' - ' + '2' },
         { value: '3', text: 'bc' + ' - ' + '3' },
         { value: '4', text: 'cd' + ' - ' + '4' },
         { value: '5', text: 'de' + ' - ' + '5' }
],
item2: ''

According to the example this should work, however, if I have:

 options2: [
          { value: {a : 1, ...}, text: 'aa' + ' - ' + '1' },
          { value:  {a : 1, ...}, text: 'ab' + ' - ' + '2' },
          { value:  {a : 1, ...}, text: 'bc' + ' - ' + '3' },
          { value:  {a : 1, ...}, text: 'cd' + ' - ' + '4' },
          { value:  {a : 1, ...}, text: 'de' + ' - ' + '5' }
],
item2: {}

if I select 'aa' + ' - ' + '1' I would expect to get {a : 1, ...} as my v-model, but I am getting this { value: {a : 1, ...}, text: 'aa' + ' - ' + '1' }, which is really confusing

A populated list opens by default on clicking in the search field

The search by default on click shows a populated list. Is there a way to show only the entries related to what a user types, which does happen after the populated list is shown. But I want that populated list must not show by default on clicking in the search field.

Empty option text when value is zero

Because the buildText method does not check on null value explicitly it fails when the option value has a zero value. This results in the option text have empty strings.

How To Test model-select

How do I get a handle on the select and choose options in a nightwatch test? model-select does not appear to pass through anything like ID or class that can be used as a selector on either the drop down itself or the options.

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.