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

@fattypanda/vue-treeselect

v0.4.3

Published

A multi-select component with nested options support for Vue.js

Downloads

4

Readme

Getting Started

npm install --save @fattypanda/vue-treeselect

文档

基本文档请参考 https://vue-treeselect.js.org/

扩展

props

renderArrowIcon

自定义渲染前方箭头

类型function,默认值void 0,优先级大于slot['arrow-icon']

参数:

  • node: this.node
  • menu: this.menu
  • shouldExpand: this.shouldExpand
  • shouldShow: this.shouldShow
  • shouldFlattenOptions: instance.shouldFlattenOptions
  • arrowClass
  • h: this.$createElement
<template>
  <div id="app">
    <TreeSelect
      v-model="value"
      :options="options"
      :render-arrow-icon="({ shouldExpand, h }) => {
        return h('div', shouldExpand ? '-' : '+')
      }"
    />
  </div>
</template>

<script>
  // import the component
  import TreeSelect from '@fattypanda/vue-treeselect'
  // import the styles
  import '@fattypanda/vue-treeselect/dist/vue-treeselect.css'

  export default {
    // register the component
    components: { TreeSelect },
    data() {
      return {
        // define the default value
        value: null,
        // define options
        options: [ {
          id: 'a',
          label: 'a',
          children: [ {
            id: 'aa',
            label: 'aa',
          }, {
            id: 'ab',
            label: 'ab',
          } ],
        }, {
          id: 'b',
          label: 'b',
        }, {
          id: 'c',
          label: 'c',
        } ],
      }
    },
  }
</script>
renderOptionLabel

自定义渲染OptionLabel

类型function,默认值void 0,优先级大于slot['option-label']

参数:

  • node
  • shouldShowCount
  • count
  • labelClassName
  • countClassName
  • h: this.$createElement
<template>
  <div id="app">
    <TreeSelect
      v-model="value"
      :options="options"
      :render-option-label="({ labelClassName, countClassName, node, shouldShowCount, count, h }) => {
        return h('div', { class: labelClassName, attrs: { title: node.label } }, [
          node.label,
          shouldShowCount ? h('span', { class: countClassName }, `(${count})`) : void 0,
        ])
      }"
    />
  </div>
</template>

<script>
  // import the component
  import TreeSelect from '@fattypanda/vue-treeselect'
  // import the styles
  import '@fattypanda/vue-treeselect/dist/vue-treeselect.css'

  export default {
    // register the component
    components: { TreeSelect },
    data() {
      return {
        // define the default value
        value: null,
        // define options
        options: [ {
          id: 'a',
          label: 'a',
          children: [ {
            id: 'aa',
            label: 'aa',
          }, {
            id: 'ab',
            label: 'ab',
          } ],
        }, {
          id: 'b',
          label: 'b',
        }, {
          id: 'c',
          label: 'c',
        } ],
      }
    },
  }
</script>

slots

arrow-icon

自定义渲染前方箭头,scope为节点vue组件对象,优先级小于props.renderArrowIcon

<template>
  <div id="app">
    <TreeSelect v-model="value" :options="options" >
      <template slot="arrow-icon" slot-scope="{shouldExpand}">
        <div>{{shouldExpand? '-': '+'}}</div>
      </template>
    </TreeSelect>
  </div>
</template>

<script>
  // import the component
  import TreeSelect from '@fattypanda/vue-treeselect'
  // import the styles
  import '@fattypanda/vue-treeselect/dist/vue-treeselect.css'

  export default {
    // register the component
    components: { TreeSelect },
    data() {
      return {
        // define the default value
        value: null,
        // define options
        options: [ {
          id: 'a',
          label: 'a',
          children: [ {
            id: 'aa',
            label: 'aa',
          }, {
            id: 'ab',
            label: 'ab',
          } ],
        }, {
          id: 'b',
          label: 'b',
        }, {
          id: 'c',
          label: 'c',
        } ],
      }
    },
  }
</script>

LOGS

2020-07-15:

修改Treeselect组件

  1. 支持renderOptionLabel参数;

修改Option组件的renderLabel函数

  1. Treeselect组件获取renderOptionLabel渲染组件(保留了原本的slots['option-label']方式);
  2. 默认<label class={labelClassName}>修改为<label class={labelClassName} title={node.label}>

2020-07-14:

修改Treeselect组件

  1. 支持renderArrowIcon参数;
  2. 支持slots['arrow-icon']'

修改Option组件的renderArrow函数

  1. Treeselect组件获取renderArrowIconslots['arrow-icon']'渲染组件;