# @pluginjs/dropdown

> A flexible modern dropdown js plugin.

Latest version **0.8.16** (published 2022-08-29) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install @pluginjs/dropdown
pnpm add @pluginjs/dropdown
yarn add @pluginjs/dropdown
bun add @pluginjs/dropdown
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.16 |
| Published | 2022-08-29 |
| First published | 2017-12-26 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >= 8 |
| Dependencies | 12 |
| Unpacked size | 155.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Creation Studio Limited |
| Maintainers | thecreation, kaptinlin |

## Links

- npm: https://www.npmjs.com/package/@pluginjs/dropdown
- Repository: https://github.com/pluginjs/pluginjs
- Homepage: https://pluginjs.com
- Issues: https://github.com/pluginjs/pluginjs/issues
- npm.io page: https://npm.io/package/@pluginjs/dropdown

## Dependencies (12)

- [popper.js](https://npm.io/package/popper.js.md) 1.16.1
- [@pluginjs/is](https://npm.io/package/@pluginjs/is.md) ^0.8.9
- [@pluginjs/dom](https://npm.io/package/@pluginjs/dom.md) ^0.8.10
- [@pluginjs/events](https://npm.io/package/@pluginjs/events.md) ^0.8.11
- [@pluginjs/styled](https://npm.io/package/@pluginjs/styled.md) ^0.8.11
- [@pluginjs/classes](https://npm.io/package/@pluginjs/classes.md) ^0.8.10
- [@pluginjs/factory](https://npm.io/package/@pluginjs/factory.md) ^0.8.10
- [@pluginjs/keyboard](https://npm.io/package/@pluginjs/keyboard.md) ^0.8.10
- [@pluginjs/template](https://npm.io/package/@pluginjs/template.md) ^0.8.10
- [@pluginjs/component](https://npm.io/package/@pluginjs/component.md) ^0.8.9
- [@pluginjs/decorator](https://npm.io/package/@pluginjs/decorator.md) ^0.8.11
- [@pluginjs/breakpoints](https://npm.io/package/@pluginjs/breakpoints.md) ^0.8.10

## Recent versions

- 0.8.16 (latest) — 2022-08-29
- 0.8.15 — 2022-01-08
- 0.8.14 — 2021-09-26
- 0.8.13 — 2021-07-19
- 0.8.12 — 2021-04-30
- 0.8.11 — 2021-03-25
- 0.8.10 — 2021-03-01
- 0.8.9 — 2020-08-27
- 0.8.8 — 2020-07-11
- 0.8.7 — 2020-03-12
- 0.8.6 — 2020-03-10
- 0.8.5 — 2020-03-04
- 0.8.4 — 2020-03-02
- 0.8.3 — 2020-02-11
- 0.8.2 — 2020-02-11
- … 58 more at https://npm.io/package/@pluginjs/dropdown/versions

## README

# Dropdown

[![npm package](https://img.shields.io/npm/v/@pluginjs/dropdown.svg)](https://www.npmjs.com/package/@pluginjs/dropdown)

A flexible modern dropdown js plugin.

**[Samples](https://codesandbox.io/s/github/pluginjs/pluginjs/tree/master/modules/dropdown/samples)**

## Introduction
### Installation

#### Yarn

```javascript
yarn add @pluginjs/dropdown
```

#### NPM

```javascript
npm i @pluginjs/dropdown
```

## Getting Started

**CDN:**

Development:

```html
<script src="https://unpkg.com/@pluginjs/dropdown/dist/dropdown.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@pluginjs/dropdown/dist/dropdown.css">
```

Production:

```html
<script src="https://unpkg.com/@pluginjs/dropdown/dist/dropdown.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@pluginjs/dropdown/dist/dropdown.min.css">
```

### Initialize

HTML:

```html
<div class="element"></div>
```

ECMAScript Module:

```javascript
import Dropdown from "@pluginjs/dropdown"
import "@pluginjs/dropdown/dist/dropdown.css"

Dropdown.of(document.querySelector('.element'), options)
```

CommonJS:

```javascript
require("@pluginjs/dropdown/dist/dropdown.css")
const Dropdown = require("@pluginjs/dropdown")

Dropdown.of(document.querySelector('.element'), options)
```

Browser:

```html
<link rel="stylesheet" href="https://unpkg.com/@pluginjs/dropdown/dist/dropdown.css">
<script src="https://unpkg.com/@pluginjs/dropdown/dist/dropdown.js"></script>
<script>
  Pj.dropdown('.element', options)
</script>
```

## API

### Options

Options are called on dropdown instances through the dropdown options itself.
You can also save the instances to variable for further use.

Name | Description | Default
--|--|--
`"theme"` | Add plugin theme option | `null`
`"panel"` | Add panel to plugin | `+`
`"trigger"` | Add trigger action | `click`
`"exclusive"` | Show exclusive true or false | `true`
`"hideOnSelect"` | Hidden or not when plugin has be select | `true`
`"hideOutClick"` | When clicking outside of the dropdown, trigger hide event | `true`
`"keyboard"` | Enable keyboard of not | `false`
`"placement"` | Set dropdown items display placement | `bottom-left`
`"imitateSelect"` | Behave like select | `false`
`"inputLabel"` | Input label with select | `false`
`"placeholder"` | Input element placeholder | `Please select`
`"icon"` | Set icon | `false`
`"select"` | Set initial select value, when imitateSelect is true | `null`
`"itemValueAttr"` | Set item tag name | `value`
`"data"` | Add a json for loading | `null`
`"width"` | Set width | `null`
`"constraintToScrollParent"` | Set constraint to scroll parent | `true`
`"constraintToWindow"` | Set constraint to window | `true`
`"templates"` | Set plugin default templates | `{}`

### Events

Events are called on dropdown instances through the dropdown events itself.
You can also save the instances to variable for further use.

Name | Description
--|--
`"ready"` | Gets fired when plugin is ready
`"enable"` | Gets fired when plugin is enabled
`"disable"` | Gets fired when plugin is disabled
`"destroy"` | Gets fired when plugin is destroy
`"hide"` | Gets fired when plugin is hidden
`"show"` | Gets fired when plugin is show
`"change"` | Gets fired when plugin is changed
`"click"` | Gets fired when plugin is clicked
`"trigger"` | Gets fired when plugin is triggerd

### Methods

Methods are called on dropdown instances through the dropdown method itself.
You can also save the instances to variable for further use.

Name | Description
--|--
`"enable"` | Enabled plugin if plugin is disabled
`"disable"` | Disable plugin
`"destroy"` | Destroy plugin
`"show"` | Show plugin
`"hide"` | Hide plugin
`"get"` | Get value by key
`"set"` | Set value by key
`"toggle"` | Active plugin or anti-active
`"update"` | Update plugin
`"replaceByData"` | Replace items by data
`"appendByData"` | Append items from data

### Classes

Name | Description | Default
--||
`"NAMESPACE"` | Declare plugin namespace | `pj-dropdown`
`"THEME"` | Declare plugin theme | `{namespace}--{theme}`
`"INPUTMODE"` | Declare input mode | `{namespace}-input`
`"SELECTMODE"` | Declare select mode | `{namespace}-select`
`"ELEMENT"` | Declare dropdown element | `{namespace}`
`"LABEL"` | Declare dropdown label | `{namespace}-label`
`"ICON"` | Declare icon element of dropdown | `{namespace}-icon`
`"ITEM"` | Declare item element of dropdown | `{namespace}-item`
`"SHOW"` | Declare show plugin | `{namespace}-show`
`"MASK"` | Declare mask of dropdown | `{namespace}-mask`
`"WRAP"` | Declare wrap of dropdown | `{namespace}-wrap`
`"PANEL"` | Declare panel element of dropdown | `{namespace}-panel`
`"PANELWRAP"` | Declare panel wrap element of dropdown | `{namespace}-panel-wrap`
`"DISABLED"` | Announce plugin is disabled | `{namespace}-disabled`
`"FOCUS"` | Declare focus status | `{namespace}-focus`
`"ACITVE"` | Declare active status | `{namespace}-active`
`"HOVER"` | Declare hover status | `{namespace}-hover`

## Browser support

Tested on all major browsers.

| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Opera |
| --------- | --------- | --------- | --------- | --------- |
| IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions|

## License

@pluginjs/dropdown is Licensed under [the GPL-v3 license](LICENSE).

If you want to use @pluginjs/dropdown project to develop commercial sites, themes, projects, and applications, the Commercial license is the appropriate license. With this option, your source code is kept proprietary.

For purchase an Commercial License, contact us purchase@thecreation.co.

## Copyright

Copyright (C) 2022 [Creation Studio Limited](creationstudio.com).

---
_Source: https://npm.io/package/@pluginjs/dropdown · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
