3.2.2 • Published 11 days ago

@lemonadejs/dropdown v3.2.2

Weekly downloads
-
License
-
Repository
-
Last release
11 days ago

LemonadeJS Dropdown

Official website and documentation is here

Compatible with Vanilla JavaScript, LemonadeJS, React, Vue or Angular.

The LemonadeJS Dropdown is a versatile solution for efficient option management. It is a framework-agnostic JavaScript plugin designed for seamless integration with Vue, React, and Angular. This feature-rich dropdown incorporates autocomplete for swift selections, grouping for organized options, and lazy loading for optimized performance, contributing to a smooth and improved user experience.

Features

  • Lightweight: The JavaScript Dropdown is only about 2 KBytes;
  • Integration: It can be used as a standalone library or integrated with any modern framework;

Getting Started

You can install using NPM or using directly from a CDN.

npm Installation

To install it in your project using npm, run the following command:

$ npm install @lemonadejs/dropdown

CDN

To use Dropdown via a CDN, include the following script tags in your HTML file:

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@lemonadejs/modal/dist/index.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@lemonadejs/modal/dist/style.min.css" />
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@lemonadejs/dropdown/dist/index.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@lemonadejs/dropdown/dist/style.min.css" />

Usage

Quick example with Lemonade

import Dropdown from '@lemonadejs/dropdown';
import '@lemonadejs/dropdown/dist/style.css'
import '@lemonadejs/modal/dist/style.css';

export default function App() {
    const self = this;

    self.data = [
        { text: "Red", value: 1 },
        { text: "Blue", value: 2 },
        { text: "Green", value: 3 },
        { text: "Yellow", value: 4 },
        { text: "Purple", value: 5 },
        { text: "Gray", value: 6 },
    ]

    return `<div>
        <Dropdown :data="self.data" :value="1" />
    </div>`
}

Quick example with React

import React, { useRef } from 'react';
import Dropdown from '@lemonadejs/dropdown/dist/react';
import '@lemonadejs/dropdown/dist/style.css'
import '@lemonadejs/modal/dist/style.css';

const data = [
    { text: "Red", value: 1 },
    { text: "Blue", value: 2 },
    { text: "Green", value: 3 },
    { text: "Yellow", value: 4 },
    { text: "Purple", value: 5 },
    { text: "Gray", value: 6 },
]
export default function App() {
    const dropdown = useRef();
    return (
        <div>
            <Dropdown data={data} ref={dropdown} value={1} />
        </div>);
}

Quick example with Vue

<template>
    <Dropdown :data="data" :value="1" />
</template>

<script>
import Dropdown from '@lemonadejs/dropdown/dist/vue'
import '@lemonadejs/dropdown/dist/style.css'
import '@lemonadejs/modal/dist/style.css'

export default {
    name: 'App',
    components: {
        Dropdown
    },
    data() {
        return {
            data: [
                { text: "Red", value: 1 },
                { text: "Blue", value: 2 },
                { text: "Green", value: 3 },
                { text: "Yellow", value: 4 },
                { text: "Purple", value: 5 },
                { text: "Gray", value: 6 },
            ]
        };
    },
}
</script>

Settings

AttributeDescription
data: Item[]An array of options to be displayed. Each item should follow the structure defined in the 'Item Details' section.
multiple?: booleanIf provided, enables the multiple selection mode, allowing users to select more than one option simultaneously.
autocomplete?: booleanIf provided, enables the autocomplete feature, displaying an input field that allows users to filter and quickly find options in the Dropdown.
value?: stringRepresents the current value or selected option in the Dropdown.
type?: stringSpecifies the type of display the Dropdown will use. It can be "searchbar" for a search bar interface, "picker" for a selection picker, or "default" for the default dropdown appearance.
insert?: booleanEnables the insert feature, allowing users to add a new option directly by typing the title text and clicking on the plus symbol.
format?: numberData format type, usually in the form of { id: name } or { value: text }
width?: numberSpecifies the width of the dropdown.
placeholder?: stringPlaceholder text to guide users in the dropdown.
url?: stringSpecifies the URL for fetching the data. Do not declare the data attribute for the url to function properly.

Item Details

AttributeDescription
value?: number or stringRepresents the identifier or unique value associated with the option.
group?: stringIndicates the group to which the option belongs, allowing for segregation and organization.
text?: stringDisplays the label or text associated with the option.
image?: stringSpecifies the image URL to be displayed alongside the option.
synonyms?: string[]Keywords for easier item identification
disabled?: booleanIndicates whether the item is currently disabled
color?: stringSpecifies the color associated with the item

Events

EventTrigger
onclose?: () => voidInvoked when the dropdown modal is closed.
onbeforeinsert?: (instance, Item) => voidInvoked before an item is added to the options through the insert feature.
oninsert?: (instance, Item) => voidInvoked after an item is added to the options through the insert feature.
onchange?: (instance, Item) => voidInvoked when the value changes.
onload?: (instance, Item) => voidInvoked when appended to the DOM.
onsearch?: (instance, Item) => voidInvoked when searching for an item.
onbeforesearch?: (instance, Item) => voidInvoked before initiating a search.
onopen?: (instance) => voidInvoked when the dropdown is opened.

License

The LemonadeJS LemonadeJS Dropdown is released under the MIT.

Other Tools

3.2.2

11 days ago

3.2.1

1 month ago

3.2.0

2 months ago

3.1.12

3 months ago

3.1.10

4 months ago

3.1.9

4 months ago

3.1.7

4 months ago

3.1.6

4 months ago

3.1.5

4 months ago

3.1.8

4 months ago

3.1.3

4 months ago

3.1.2

4 months ago

3.1.1

4 months ago

3.1.0

4 months ago

3.0.13

5 months ago

3.0.12

5 months ago

3.0.4

5 months ago

3.0.3

5 months ago

3.0.10

5 months ago

3.0.8

5 months ago

3.0.7

5 months ago

3.0.6

5 months ago

3.0.9

5 months ago

1.1.1

1 year ago

2.0.0

1 year ago

1.1.0

2 years ago