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

vue-async-tree

v1.0.4

Published

[![NPM version](https://img.shields.io/npm/v/vue-async-tree.svg?style=flat-square)](https://www.npmjs.com/package/vue-async-tree)

Downloads

2

Readme

vue-async-tree

NPM version

Async featured Tree Component for Vue, Only tested on Vue 3.

Install

# with npm
npm install vue-async-tree

# or with Yarn
yarn add vue-async-tree

Simple Example

<template>
  <Tree
    :initialData="data"
    :options="options"
    :expandable="expandable"
    :fetchData="fetchData"
  />
</template>

<script setup>
  import Tree from "vue-async-tree";
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); // for fetch

  function expandable(item) {
    return item.type === "folder";
  }

  //runs when item is expandable or item's children key is not array
  async function fetchData(item) {
    // item is Proxy so can edit as you want
    //  {
    //     _id: "62bd57977de51fb403142fbb",
    //     name: "src",
    //     type: "folder",
    //     items: []
    //   }

    await sleep(300); // fetching

    item[options.children].push({
      _id: "62bf4c269502ccd49487ac6c",
      name: "index.js",
      type: "file",
    });
  }

  const data = [
    {
      _id: "62bd57977de51fb403142fbb",
      name: "src",
      type: "folder",
      items: [],
    },
  ];

  const options = {
    id: "_id",
    text: "name",
    group: "type",
    children: "items",
  };
</script>

Slots

Model is item

| slot | props | | :---------- | ---------------------------------------------------------- | | item-toggle | model, expandable, isExpanded, isLoading, expand, collapse | | item-icon | model | | item-text | model |

Example

<template>
  <Tree
    :initialData="data"
    :options="options"
    :expandable="expandable"
    :fetchData="fetchData"
  >
    <template
      #item-toggle="{ model, expandable, isExpanded, isLoading, expand, collapse }"
    >
      <span v-if="isLoading">Loading</span>

      <span v-else-if="expandable(model)">
        <!-- .stop modified required -->
        <button v-if="isExpanded" @click.stop="collapse(model)">
          collapse
        </button>
        <button v-else @click.stop="expand(model)">expand</button>
      </span>
    </template>

    <template #item-icon="{ model }">
      <p v-if="model.type === 'folder'">folderIcon</p>
    </template>

    <template #item-text="{ model }"> - {{ model.name }} - </template>
  </Tree>
</template>

Exposes

| key | value | | :----------- | ----------------- | | select | function(item) | | expand | function(item) | | collapse | function(item) | | selectedItem | item | | loadingIds | Set (id of items) |

Styles

Theese are deafults. If you want to change you must use !important.

.vue-async-tree-wrapper {
  padding: 0px;
}

.vue-async-tree-item {
  cursor: pointer;
  line-height: 1.5;
  list-style-type: none;
  margin: 0px;
}

.vue-async-tree-row {
  display: flex;
}

.vue-async-tree-selected {
  color: #1e1f1f;
  background-color: #dde2e4 !important;
}

.vue-async-tree-toggle {
  width: 35px;
}

.vue-async-tree-loading {
  width: 35px;
  height: 35px;
}

@-webkit-keyframes fa-spin {
  0% {
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
  }

  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}

@keyframes fa-spin {
  0% {
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
  }

  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}

.vue-async-tree-spin {
  -webkit-animation-name: fa-spin;
  animation-name: fa-spin;
  -webkit-animation-delay: var(--fa-animation-delay, 0);
  animation-delay: var(--fa-animation-delay, 0);
  -webkit-animation-direction: var(--fa-animation-direction, normal);
  animation-direction: var(--fa-animation-direction, normal);
  -webkit-animation-duration: var(--fa-animation-duration, 2s);
  animation-duration: var(--fa-animation-duration, 2s);
  -webkit-animation-iteration-count: var(
    --fa-animation-iteration-count,
    infinite
  );
  animation-iteration-count: var(--fa-animation-iteration-count, infinite);
  -webkit-animation-timing-function: var(--fa-animation-timing, linear);
  animation-timing-function: var(--fa-animation-timing, linear);
}

.vue-async-tree-spinner {
  width: 25px;
}

.vue-async-tree-collapse-icon {
  width: 25px;
  height: 25px;
}

.vue-async-tree-expand-icon {
  width: 25px;
  height: 25px;
}