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-checkbox-count

v1.0.11

Published

一个下拉多选框组件,能统计超出父组件长度部分的溢出个数,适用于Vue

Downloads

4

Readme

vue-checkbox-count

该组件是 DropdownMenu下拉菜单 与 Checkbox复选框 的结合,特点在于在显示栏处,若多选项溢出显示区域则在最后标记其溢出个数。

该组件采用 [email protected]+ [email protected] + [email protected] + [email protected] 实现! 样式 CSS 使用 box-sizing: border-box; 模式! 开箱即用!

vue-checkbox-count 适用于 移动端, Vue3 + Typescript 环境!

Install & Use

npm install vue-checkbox-count
# or
yarn add vue-checkbox-count
# or
pnpm i vue-checkbox-count

Import and register component

Global

import { createApp } from "vue";
import App from "./App.vue";

import CheckboxCount from "vue-checkbox-count";
import "vue-checkbox-count/style.css";

const app = createApp(App);
app.use(CheckboxCount);
app.mount("#app");

Local

<script setup lang="ts">
import { CheckboxCount } from "vue-checkbox-count";
import "vue-checkbox-count/style.css";
</script>

基本使用

<script setup lang="ts">
const list = [
  {
    name: "Tom",
  },
  {
    name: "Jerry",
  },
  {
    name: "Lewis",
  },
  {
    name: "Shelly",
  },
];
const value = ref([]);
</script>
<template>
  <CheckboxCount v-model="value" :list="list" name="name"></CheckboxCount>
</template>

自定义过滤器图标

<template>
  <CheckboxCount v-model="value" :list="list" name="id">
    <template #panelFilter></template>
  </CheckboxCount>
</template>

自定义箭头图标

<template>
  <CheckboxCount v-model="value" :list="list" name="id">
    <template #panelArrow></template>
  </CheckboxCount>
</template>

自定义多选框图标

<template>
  <CheckboxCount v-model="value" :list="list" name="id">
    <template #checkboxIcon="props">
      <div class="square" :class="{ checked: props.checked }"></div>
    </template>
  </CheckboxCount>
</template>

自定义多选框内容文字

<template>
  <template #checkboxText="props">
    <div style="color: aquamarine">{{ props.listItem }}</div>
  </template>
</template>

APIs

Props

| 参数 | 说明 | 类型 | 默认值 | | ---------------------- | --------------------------------------- | -------------------- | --------- | | v-model | 当前选中项对应的 value | Array | [] | | list | 选项数组 | Array | [] | | disabled | 是否禁用菜单 | boolean | false | | width | 组件宽度,默认单位 px | string | number | 300 | | height | 下拉框最大高度,默认单位 px | string | number | 200 | | color | 文字及图标颜色 | string | "#93acd3" | | direction-down | 菜单向下展开 | boolean | true | | duration | 动画时长,单位秒,设置为 0 可以禁用动画 | string | number | 0.2 | | z-index | 菜单栏 z-index 层级 | string | number | 10 | | overlay | 是否显示遮罩层 | boolean | true | | close-on-click-overlay | 是否在点击遮罩层后关闭菜单 | boolean | true | | close-on-click-outside | 是否在点击外部元素后关闭菜单 | boolean | true | | placeholder-text | 占位文字 | string | "Select" | | name | 标识符,唯一的字符串 | string | "" | | checkbox-disabled-name | 标识符,根据此属性判断是否禁用复选框 | string | "" | | max | 最大选项可选数,-1 为无限制 | string | number | -1 |

Events

| 事件名 | 说明 | 回调参数 | | ------ | ----------------------------- | -------- | | change | 点击选项导致 value 变化时触发 | value | | open | 打开菜单栏时触发 | - | | close | 关闭菜单栏时触发 | - | | opened | 打开菜单栏且动画结束后触发 | - | | closed | 关闭菜单栏且动画结束后触发 | - |

slotProps

| 参数 | 说明 | 类型 | 默认值 | | -------- | ---------------------------------- | ------- | ------ | | checked | 是否选中当前项 | boolean | false | | listItem | 当前项数据(仅#checkboxText 生效) | string | - |

updateScroll 方法

通过 ref 可以获取到 Checkbox 实例并调用实例方法,详见组件实例方法

| 事件名 | 说明 | 回调参数 | | ------------ | -------------------------------- | -------- | | updateScroll | 更新组件内部对页面滚动状态的控制 | - |