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

selectbar

v1.0.1

Published

select、sortable.js

Downloads

5

Readme

select-bar

下拉可拖动组件

1. 效果

效果图片

2. 介绍

该组件是基于vue2.0的一个组件,同时引入了Sortable.js,这是一个可以拖动排序的插件,由于该插件的兼容性并不是太好(IE10以下都不兼容),所以在该组件同时增加了手动输入的功能。

3. 使用方法

安装

npm i selectbar

引用

在需要使用该组件的地方

import selectBar from 'selectbar';

components: {
  selectBar
},

在标签中使用

<select-bar 
@addSection="addSection" 
@editChapter="editChapter" 
@deleteChapter="deleteChapter"
@editSection="editSection" 
@deleteSection="deleteSection" 
@chapterHandleOrder="chapterHandleOrder"
@sectionHandleOrder="sectionHandleOrder"
@sectionDragOrder="sectionDragOrder"
@chapterDragOrder="chapterDragOrder"
:color="color" 
:accordion="accordion"
:defaultProps="defaultProps" 
:data="data"></select-bar>

组件中的参数

  • data: 传入的数据格式
data: {
  parent: [
    {
      name: '第一级',
      orderNum: 1,
      id: '1123412341',
      children: [
        {
          name: '第一节',
          orderNum: 1,
          id: '23412341234'
        },
        {
          name: '第二节',
          orderNum: 2,
          id: '213412341234'
        }
      ]
    },
    {
      name: '第二级',
      orderNum: 2,
      id: '123412341234',
      children: [
        {
          name: '第一节',
          orderNum: 1,
          id: '123412341234'
        },
        {
          name: '第二节',
          orderNum: 2,
          id: '123412341234'
        }
      ]
    }
  ]
},
  • defaultProps:映射输入的参数, chapter:是父集的key, children:是子集的key, orderNum:是对应的排序的key
defaultProps: {
  chapter: 'parent',
  children: 'children',
  orderNum: 'orderNum'
}
  • color: 组件的颜色 chapterBackground: 章的背景颜色 sectionBackground:小节的背景颜色 chapterColor:章的文字颜色 sectionColor:小节的文字颜色
color: {
  chapterBackground: '#E6ECF0',
  sectionBackground: '#F4F7F9',
  chapterColor: '#656565',
  sectionColor: '#999999'
}
  • width 组件的宽度
type: String,
default: '100%'
  • accordion 是否每次只展开一个
type: Boolean,
default: false
  • sectionMarginTop 小节的top值
type: Number,
default: 10
  • chapterMarginTop 章的top值
type: Number,
default: 10
  • isSectionSortable 小节是否可以拖动
type: Boolean,
default: true
  • isChaterSortable 章是否可以拖动
type: Boolean,
default: true
  • isSectionClickToEdit 是否可以通过点击小节本身触发小节编辑事件
type: Boolean,
default: false
  • isShowChapterOrder 是否显示chapter手动排序输入框
type: Boolean,
default: true
  • isShowSectionOrder 是否显示section手动排序输入框
type: Boolean,
default: true
  • maxLength 可以输入最大长度
type: Number,
default: 2

组件中的事件

* 编辑章
// item: 被编辑章对应的data内容
editChapter (item) {},
* 删除章
// item: 被删除章对应的data内容
deleteChapter (item) {},
* 增加小节
// item: 添加小节对应的data内容
addSection (item) {},
* 编辑小节
// item: 编辑小节对应的data内容
editSection (item) {},
* 删除小节
// item: 删除小节对应的data内容
deleteSection (item) {},
* 章通过手动输入改变排序
// order: 手动输入的排序值
// item: 被编辑的章对应的data内容
chapterHandleOrder(order, item) {},
* 小节通过手动输入改变排序
// order: 手动输入的排序值
// item: 被编辑的小节对应的data内容
sectionHandleOrder(order, item) {},
* 章通过拖动改变排序
// order: 为章拖动后新位置的排序
// item: 被拖动的章对应的data内容
chapterDragOrder(order, item) {}
* 小节通过拖动改变排序
// order: 为小节拖动后新位置的排序
// item: 被拖动的小节对应的data内容
sectionDragOrder(order, item) {},