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

lse-tree-selection

v1.2.0

Published

Dependency free web component enabling consistent interactivity of tree selection views.

Downloads

34

Readme

LSE-TREE-SELECTION

A dependency free web component enabling consistent interactivity of a tree selection view. It's usable both in client- and server side rendering settings (csr & ssr).

Showcase

E2E-Tests

Table of Contents

Installation

You can install the web component's javascript into your project with your npm-manager of choice. For example:

npm install 'lse-tree-selection'

Import from the package to make sure its js contents are loaded in places of usage. After that interactivity should work for the introduced HTML tags as defined below.

import * as LseTreeSelection from "lse-tree-selection"

HTML-API

<lse-tree-selection>

Attributes

| Attribute | Description | Possible Values | Required | |------------------|-----------------------------------------------------------|-------------------------------|----------------| | init-dimension | Identifier to identify the selection hierarchy uniquely. | A distinctive string | yes | | init-data | Holder of data selection structure in csr-setting | Stringified JSON string, see below | csr only |

The data selection structure is defined as follows in recursive manner:

// Leaf Node Example
{
    id: 1 // Numeric identifier of selection option, must be unique within the `<lse-tree-selection>` instance
    label: "Label for option 1" // String that is visually displayed
    children: [] // Array that holds objects of the exact structure as defined in this example or is empty in case of Leaf Nodes
}

Inner-HTML Characteristics

  • Empty in csr-etting
  • In ssr-setting a structure of nested <lse-tree-selection-node>

<lse-tree-selection-node>

If the attribute init-data is given in <lse-tree-selection> as explained above, these nodes are automatically rendered, when the <lse-tree-selection> DOM node is mounted.

In a ssr-setting the following characterics must be satisfied.

Attributes

| Attribute | Description | Possible Values | Required | |------------------|-----------------------------------------------------------|-------------------------------|----------------| | id | Identifier to identify the selection node uniquely within the lse-tree-selection instance | A numeric identifier | yes |

Inner-HTML Characteristics

The Inner-HTML must contain an <input> element of type checkbox and with a value that corresponds to the id-attribute of the containing <lse-tree-selection-node> DOM node.

Event-API

With each selection the <lse-tree-selection> element dispatches a custom TreeSelectionChangeEvent. Hierarchically higher DOM Nodes should listen to lse-tree-selection-change to get notified about selection changes as well.

TreeSelectionChangeEvent

This is a custom Event, whose detail property refers to an object with the following properties

  • dimension_key: Corresponds to the attribute value init-dimension of <lse-tree-selection>
  • selected_ids : An Array numbers, that correspond to the selected leaf nodes identifiers of the corresponding selection hierarchy.

Style-API

The component doesn't make any assumptions about its CSS styling. As showed in the examples CSS can leverage the high specificity of the introduced selection tags, which should help to define enterprise-wise consistent styling of such components. The component doesn't make use of any shadow DOM feature.