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

@mtn-ui/utils

v0.0.6

Published

MTN UI Utils

Readme

@mtn-ui/utils

MTN UI 工具函数包,基于 VueUse 构建。

安装

pnpm add @mtn-ui/utils @vueuse/core

目录结构

packages/utils/src/
├── common.ts        # 通用工具函数
├── function.ts      # 函数工具(防抖、节流)
├── state.ts         # 状态管理工具
├── dom.ts           # DOM 操作工具
├── interaction.ts   # 交互工具(鼠标、滚动等)
├── media.ts         # 媒体查询工具
├── types.ts         # 类型定义
└── index.ts         # 主入口(重新导出所有内容)

功能分类

通用工具 (common.ts)

  • classNames - 格式化类名

函数工具 (function.ts)

  • useDebounceFn - 防抖函数
  • useThrottleFn - 节流函数

状态管理 (state.ts)

本包重新导出了 VueUse 的状态管理函数,包括:

  • useToggle - 切换布尔值
  • useCounter - 计数器
  • useLocalStorage - 本地存储
  • useSessionStorage - 会话存储

DOM 操作 (dom.ts)

  • onClickOutside - 点击外部区域
  • useEventListener - 事件监听
  • useElementSize - 元素尺寸
  • useResizeObserver - 尺寸观察
  • useFocus - 焦点管理
  • useHover - 悬停状态
  • useClipboard - 剪贴板操作

交互工具 (interaction.ts)

  • useMouse - 鼠标位置
  • useScroll - 滚动位置
  • useWindowSize - 窗口尺寸

媒体查询 (media.ts)

  • useMediaQuery - 媒体查询
  • usePreferredDark - 系统暗色偏好
  • useDark - 暗色模式
  • useColorMode - 颜色模式

使用方式

全量导入(推荐)

import { classNames, useDebounceFn, useToggle } from '@mtn-ui/utils'

按分类导入

// 通用工具
import { classNames } from '@mtn-ui/utils/common'

// 函数工具
import { useDebounceFn, useThrottleFn } from '@mtn-ui/utils/function'

// 状态管理
import { useToggle, useCounter } from '@mtn-ui/utils/state'

// DOM 操作
import { onClickOutside, useElementSize } from '@mtn-ui/utils/dom'

// 交互工具
import { useMouse, useScroll } from '@mtn-ui/utils/interaction'

// 媒体查询
import { useDark, useColorMode } from '@mtn-ui/utils/media'

使用示例

防抖和节流

import { useDebounceFn, useThrottleFn } from '@mtn-ui/utils'

// 防抖
const debouncedSearch = useDebounceFn((query: string) => {
  console.log('Search:', query)
}, 300)

// 节流
const throttledScroll = useThrottleFn(() => {
  console.log('Scrolled')
}, 100)

状态管理

import { useToggle, useCounter, useLocalStorage } from '@mtn-ui/utils'

// 切换状态
const [isOpen, toggle] = useToggle(false)

// 计数器
const { count, inc, dec, reset } = useCounter(0)

// 本地存储
const stored = useLocalStorage('key', 'default-value')

DOM 操作

import { onClickOutside, useElementSize } from '@mtn-ui/utils'
import { ref } from 'vue'

const target = ref<HTMLElement>()

// 点击外部区域
onClickOutside(target, () => {
  console.log('Clicked outside')
})

// 元素尺寸
const { width, height } = useElementSize(target)

更多文档

查看 VueUse 官方文档 了解更多功能。