npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@miraidesigns/select

v1.0.3

Published

Mirai Designs Framework: Select module

Downloads

4

Readme

Selects

Selects show a set of options the user can choose one from.
Serves as an alternative to the native <select> element.
Requires the List and Menu modules.


HTML

<div class="mdf-select">
    <button class="mdf-select__button" aria-haspopup="listbox" aria-labelledby="select-label select-text">
        <span id="select-label" class="mdf-select__label">Select</span>
        <span id="select-text" class="mdf-select__text"></span>

        <span class="mdf-select__icon">
            <svg class="mdf-icon" viewBox="0 0 24 24" aria-hidden="true">
                <use href="icons.svg#arrow-keyboard"></use>
            </svg>
        </span>
    </button>

    <div class="mdf-select__menu mdf-menu">
        <ul class="mdf-list" role="listbox" aria-labelledby="select-label" tabindex="-1">
            <li class="mdf-list__item mdf-list__item--selected" role="option" data-value="1">Option 1</li>
            <li class="mdf-list__item" role="option" data-value="2">Option 2</li>
            <li class="mdf-list__item" role="option" data-value="3">Option 3</li>
        </ul>

        <input class="mdf-select__input" type="hidden" name="option" />
    </div>
</div>

Sass

// Include default styles without configuration
@forward '@miraidesigns/select/styles';
// Configure appearance
@use '@miraidesigns/select' with (
    $variable: value
);

@include select.styles();

TypeScript

import { MDFSelect } from '@miraidesigns/select';

new MDFSelect(document.querySelector('.mdf-select'));

Attributes

Please see the WAI-ARIA page for attributes and best practices regarding listboxes.

| Name | Element | Description | | ------------ | ------- | ------------------------------------------------------------------------- | | data-value | <li> | The option's value, equivalent to a native <option value=""> attribute. |

Classes

| Name | Type | Description | | ----------------------------- | -------------- | ----------------------------------------------------- | | mdf-select | Parent | Select container element | | mdf-select__button | Child / Parent | Select button element that activates the menu | | mdf-select__label | Child | Select label element | | mdf-select__label--floating | Modifier | Moves the label above the button | | mdf-select__text | Child | Select text element | | mdf-select__icon | Child | Select arrow icon element | | mdf-select__input | Child | Select hidden input element, holds the selected value | | mdf-list__item--selected | Modifier | Marks the list item as selected |

Events

| Name | Data | Description | | ------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------- | | MDFSelect:opened | null | Fires when the select menu opens | | MDFSelect:changed | {item: HTMLElement, text: string, value: string} | Fires whenever the active select item changes. Includes the item itself, its text and input value | | MDFSelect:closed | null | Fires when the select menu closes |

Properties

| Name | Type | Description | | ------------------------ | --------------------- | --------------------------------------------------- | | .container | HTMLElement | Returns the select container element | | .items | HTMLElement[] | Returns an Array holding all menu items | | .menu | HTMLElement | Returns the menu element | | .text | string | Get or set the select button text | | .value | string | Get or set the select hidden input value | | .isActive() | (): boolean | Returns wether or not the menu is currently visible | | .getSelectedElem() | (): HTMLElement | Returns the currently selected item | | .setSelectedElem(elem) | (HTMLElement): void | Set the given element as selected |