2.0.1 • Published 3 years ago

@revolist/revo-dropdown v2.0.1

Weekly downloads
32
License
MIT
Repository
github
Last release
3 years ago

revo-dropdown

Minimalistic dropdown webcomponent. After long search we couldn't find any cross platform and had to build our own inspired by the latest trends.

AutocompleteRegular select

Getting Started

To start building a new web component using Stencil, clone this repo to a new directory:

npm i @revolist/revo-dropdown

Module import

import * as loader from '@revolist/revo-dropdown/loader';
if (loader.defineCustomElements) {
  loader.defineCustomElements();
}

Script tag

  • Put a script tag similar to this <script src='https://unpkg.com/revo-dropdown@latest/dist/revo-dropdown.js'></script> in the head of your index.html

Usage

Then you can use the element anywhere in your template, JSX, html etc

<revo-dropdown data-label="name" autocomplete="true" placeholder="Philosophers" max-height="300"></revo-dropdown>
<script type="module">
  const people = [
  {
    eyeColor: 'green',
    name: 'Samantha Molina',
  },
  {
    eyeColor: 'green',
    name: 'Weber Henderson',
  }];
  const dropdowns = document.querySelectorAll('revo-dropdown');
  for (var q = 0; q < dropdowns.length; q++) {
    dropdowns[q].source = people;
  } 
</script>

Need help? Check out docs here.

API

Properties

PropertyAttributeDescriptionTypeDefault
appendToappend-toWhere to append element"body" \| "current"'body'
autoCloseauto-closeShould dropdown autoclose on changeValuebooleantrue
autoFocusauto-focusbooleanfalse
autocompleteautocompletebooleanfalse
currentFiltercurrent-filterFilter valueanyundefined
dataIddata-idDefine object mapping for id/valuestringundefined
dataLabeldata-labelDefine object mapping for labelsstringundefined
filterfilterFilter criteria"contains" \| "start"undefined
hasFilterhas-filterbooleantrue
maxHeightmax-heightnumberundefined
placeholderplaceholderPlaceholder textstring'Select'
source--Define object mapping for id/valueany[][]
valuevalueSelected valueanyundefined

Events

EventDescriptionType
changedWhen value changedCustomEvent<{ val: any; originalEvent?: MouseEvent; }>
closeBefore element close, can be preventedCustomEvent<any>
openBefore element open, can be preventedCustomEvent<any>

Methods

doChange(val: any, originalEvent?: MouseEvent) => Promise<void>

Change value

Returns

Type: Promise<void>

doClose(isDisconnected?: boolean) => Promise<void>

Close dropdown

Returns

Type: Promise<void>

doOpen() => Promise<void>

Open dropdown

Returns

Type: Promise<void>


Built with StencilJS