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 🙏

© 2026 – Pkg Stats / Ryan Hefner

combination-drawer-react

v1.0.5

Published

基于react抽屉嵌套,类似手风琴效果

Readme

描述

基于 react 抽屉嵌套,类似手风琴效果

效果如图

效果如图

安装

npm install combination-drawer-react --save

引入方式

import { CombinationDrawer } from 'combination-drawer-react'; // 项目没有用TS,可以这样引入;
const { CombinationDrawer } = require('combination-drawer-react'); // 项目中使用了TS,可以这样引入;

使用方法

数据格式规定如下:

const list = [
  {
    key: '0', // 必须
    title: '',
    // width: 200, 可有可无
    transition: 0, // 必须
    notExpanded: false, // 必须
    fatherSonConnection: '-1', // 必须,一级为-1,往下叠加
    value: ( // 必须
      <div style={{ width: '100px', height: '20px' }}>
        <div onClick={() => indexFilter('0', '点击我 1')}>点击我 1</div>
        <div onClick={() => indexFilter('0', '点击我 2')}>点击我 2</div>
        <div onClick={() => indexFilter('0', '点击我 3')}>点击我 3</div>
      </div>
    ),
    state: true, // 必须第一级必须为 true 往下为 false
  },
  {
    key: '1',
    title: '',
    // width: 200,
    transition: 0,
    notExpanded: false,
    fatherSonConnection: '0',
    value: (
      <div style={{ width: '160px', height: '20px' }}>
        <div onClick={() => indexFilter('1', '一级点击我 1')}>一级点击我 1</div>
        <div onClick={() => indexFilter('1', '一级点击我 2')}>一级点击我 2</div>
      </div>
    ),
    state: false,
  },
]

const list1=[{}] // 自己的数据
const drawers = useRef(null);
const [drawerShow, setDrawerShow] = useState(false);
const [filters, setFilters] = useState({});
const indexFilter = (index, title) => {
  // 进入下一层抽屉
  setFilters({ index, title });
};
const submitClose = (index) => {
  // 提交事件后关闭该层抽屉
  if (drawers) {
    drawers.current.getInfo(index);
  }
};
const [newList, setNewList] = useState(list);
const onSetDrawerShows = (index) => {
  if (index === 1) {
    setNewList(list);
  }
  if (index === 2) {
    setNewList(list1);
  }
  setDrawerShow(true);
};
return (
  <div>
    <div onClick={() => onSetDrawerShows(1)} style={{ cursor: 'pointer' }}>
      点击1
    </div>
    <div onClick={() => onSetDrawerShows(2)} style={{ cursor: 'pointer' }}>
      点击2
    </div>
    <div>
      <CombinationDrawer
        ref={drawers}
        list={newList} // 数据
        drawerShow={drawerShow} // 抽屉开关true/false
        setDrawerShow={setDrawerShow} // 关闭抽屉事件
        filters={filters} // 进入下一层抽屉参数(index,和 标题)
        titles={true} // 是否显示顶部标题层级关系:如(第一层/第二次/第三层)并点击返回该层抽屉
        redundantWidth={35} // 每层抽屉露出的宽度
        initial={false} // 设置true,初始化最多展示1个抽屉;
      />
    </div>
  </div>
);