# vue-multiple-select-helper

> Universal multiple select helper component for Vue

Latest version **0.0.2** (published 2017-10-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-multiple-select-helper
pnpm add vue-multiple-select-helper
yarn add vue-multiple-select-helper
bun add vue-multiple-select-helper
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2017-10-01 |
| First published | 2017-10-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Raymond Ralibi |
| Maintainers | ralibi |
| Keywords | helper, multiple, select, slot, vue |

## Links

- npm: https://www.npmjs.com/package/vue-multiple-select-helper
- Repository: https://github.com/ralibi/vue-multiple-select-helper
- Homepage: https://github.com/ralibi/vue-multiple-select-helper#readme
- Issues: https://github.com/ralibi/vue-multiple-select-helper/issues
- npm.io page: https://npm.io/package/vue-multiple-select-helper

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2017-10-01
- 0.0.1 — 2017-10-01

## README

Universal multiple select helper component for Vue

## Installation

npm:

```shell
npm install vue-multiple-select-helper --save
```

## Usage

```js
import VueMultipleSelectionHelper from 'vue-multiple-select-helper'
Vue.use(VueMultipleSelectionHelper)
```

```vue
<template>
  <div class="c-cmyk-select-demo">

    <h2>CMYK Multiple</h2>

    <multiple-select-helper
      :data="colors"
      :initialSelection="preselectedMultipleColors"
      v-model="clickedMultipleColor"
      @selection-change="handleMultipleSelectionChange">
      <ul v-for="color in colors">
        <li :class="{selected: isMultipleSelected(color)}">
          <h5>{{ color.name }}</h5>
          <button @click.prevent="clickedMultipleColor = color">
            {{ isMultipleSelected(color) ? "Deselect" : "Select" }}
          </button>
        </li>
      </ul>
    </multiple-select-helper>

    <h3>Recent Multiple Clicked</h3>
    <pre>{{ recentMultipleColor }}</pre>
    <h3>Current Multiple Selection</h3>
    <pre>{{ currentMultipleSelection }}</pre>

    <hr/>

    <h2>CMYK Single</h2>

    <multiple-select-helper
      :data="colors"
      :initialSelection="preselectedSingleColor"
      :multiple="false"
      v-model="clickedSingleColor"
      @selection-change="handleSingleSelectionChange">
      <ul v-for="color in colors">
        <li :class="{selected: isSingleSelected(color)}">
          <h5>{{ color.name }}</h5>
          <button @click.prevent="clickedSingleColor = color">
            {{ isSingleSelected(color) ? "Deselect" : "Select" }}
          </button>
        </li>
      </ul>
    </multiple-select-helper>

    <h3>Recent Single Clicked</h3>
    <pre>{{ recentSingleColor }}</pre>
    <h3>Current Single Selection</h3>
    <pre>{{ currentSingleSelection }}</pre>

  </div>
</template>

<script>
  export default {
    name: 'c-cmyk-select-demo',
    data () {
      return {
        colors: [
          {
            id: '1',
            name: 'Cyan'
          },
          {
            id: '2',
            name: 'Magenta'
          },
          {
            id: '3',
            name: 'Yellow'
          },
          {
            id: '4',
            name: 'Black'
          }
        ],

        // Multiple selection
        preselectedMultipleColors: [
          {
            id: '2',
            name: 'Magenta'
          }
        ],
        currentMultipleSelection: [],
        clickedMultipleColor: {},
        recentMultipleColor: null,

        // Single selection
        preselectedSingleColor: {
          id: '4',
          name: 'Black'
        },
        clickedSingleColor: {},
        currentSingleSelection: {},
        recentSingleColor: null
      }
    },

    methods: {
      // Multiple selection
      handleMultipleSelectionChange (selection, recent) {
        this.currentMultipleSelection = selection
        this.recentMultipleColor = recent
      },
      isMultipleSelected (val) {
        return this.currentMultipleSelection.findIndex((item) => item.id === val.id) !== -1
      },

      // Single selection
      handleSingleSelectionChange (selection, recent) {
        this.currentSingleSelection = selection
        this.recentSingleColor = recent
      },
      isSingleSelected (val) {
        return this.currentSingleSelection.id === val.id
      }
    }
  }
</script>

<style scoped>
  li.selected h5,
  li.selected button {
    font-weight: bold;
  }
</style>
```

### Attributes
| Attribute | Description | Required | Type | Accepted values | Default |
|---|---|---|---|---|---|
| `data` | Selection domain | Yes | `Array` of object | — | — |
| `multiple` | Selection mode | No | `Boolean` | — | `true` |
| `initialSelection` | Initial selection | Yes | `Array` of object if multiple is `true` or `Object` if multiple is `false` | — | — |
| `selectionKey` | — | No | `String` | — | `'id'` |
| `value` (`v-model`) | — | Yes | `Object` | `null` | `null` |
### Slot
| Name | Description |
|---|---|
| — | Content of wrapped table/list |
### Events
| Name | Description | Parameters |
|---|---|---|
| `selection-change` | Triggers when user change `v-model` value (by clicking an item) | current selection array/object and object of clicked item |

---
_Source: https://npm.io/package/vue-multiple-select-helper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
