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

@keenmate/svelte-treeview

v1.2.12

Published

The most elaborate treeview for svelte on earth (or even in our galaxy).

Downloads

252

Readme

Svelte Treeview

The most elaborate treeview for svelte on earth (or even in our galaxy).

Features

  • load new nodes when expanding
  • choose what object properties to use to get necessary information (id, path, ...)
  • enable checkboxes on whole tree or just per node
  • recursive seletion mode, where leafes can be selected
  • build-in support for search
  • drag and drop functionality controlable per node
  • context menu
  • keyboard navigation

Instalation

install the package @keenmate/svelte-treeview using your favourite package manager.

[!warning] Font awesome is required for expand/collapse icons. If you wish to not use FA, you need to change all icons in classes properties

Minimal usage

Tree and treeId are only mandatory attributes. Tree has to be list of nodes. Only mandatory property of node is nodePath. You can specify which keys to use for what properties by setting props.

<script lang="ts">
 import { TreeView } from '$lib/index.js';

 let tree = [
  { nodePath: 'animals', title: 'Animals', hasChildren: true },
    //...
  { nodePath: 'animals.insects.butterflies', title: 'Butterflies' }
 ];
</script>

<TreeView {tree} treeId="my-tree" let:node>
 {node.title}
</TreeView>

For more examples see src/routes/

[!note] Both id and path is required for tree to work. By default tree uses nodePath property for both. So if you change propery fro path, you need to also change id property. You can change both using props attribute.

Properties

| Name | Type | Default | Description | | ---------------------- | ------------------------------------------------------------------ | ------- | ----------------------------------------------------------------------------------------------------- | | treeId | string | | value used to generate ids of nodes | | tree | array of nodes | | represents tree strucuture | | value | array of selected nodeIds | [] | | | verticalLines | bool | false | show vertical guide lines | | readonly | bool | false | dont allow selection and drag and drop | | separator | string | "." | | | recursiveSelection | bool | false | changes behavior of selection, see Selection | | selectionMode | SelectionModes | none | changes selection mode, see Selection | | onlyLeafCheckboxes | bool | false | hides non leaf checkboxed, see Selection | | hideDisabledCheckboxes | bool | false | hides checkboxes instead of disabling, see Selection | | loadChildrenAsync | ExpandedCallback | null | function that is called when node is expanded, see Async loading | | showContextMenu | bool | false | On right click dispaly context menu defined in context-menu slot, see Context menu | | expansionThreshold | number | 0 | Expand all nodes when there is less than number provided | | customClasses | Partial | {} | changes classes used on same elements, see Custom classes | | filter | (node: Node) => boolean or null | null | function that is used for fitlering. It is called on every node | | dragAndDrop | bool | false | enables drag and drop, see Drag and drop | | dropDisabledCallback | (draggendNode: Node, targetNode: Node) => Promise or null | null | function called when draging over new node, see Drag and drop | | useKeyboardNavigation | bool | false | enables keyboard navigation , see Keyboard navigation | | logger | ((...data: any[]) => void) or null | null | function that acts as logger for tree, mostly used for debugging |

Selection

Async loading

Context menu

Custom classes

Drag and drop

[!NOTE]
In memory drag and drop is not yet supported. Tree just dispatches moved event with dragged node(node), target node (target) and insertion type (insertType). In future, this package will export function, that will allow you to easily compute new tree on frontend.

Keyboard navigation

Enable keyboard navigation by setting useKeyboardNavigation to true.

Use arrows to navigata tree. First you need to focus some node, you can use focusNode to do that. Use Enter or Space to select checkbox.