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

@composy/pivot-table-vue

v0.0.1

Published

Vue components for @composy/pivot-table-core

Readme

@composy/pivot-table-vue

LDesign 数据透视表 Vue 3 适配包 — 基于 @composy/pivot-table-core 核心库的 Vue 组合式 API。

安装

npm install @composy/pivot-table-vue

需要同时安装 @composy/pivot-table-core 作为依赖。

快速开始

组件用法

<template>
  <PivotTable
    :data="data"
    :rows="['region']"
    :cols="['product']"
    :values="[{ field: 'sales', aggregator: 'sum' }]"
    theme="light"
    :show-row-totals="true"
    :sortable="true"
    @cell-click="onCellClick"
  />
</template>

<script setup lang="ts">
import { PivotTable } from '@composy/pivot-table-vue'

const data = [
  { region: 'East', product: 'Phone', sales: 1000 },
  { region: 'East', product: 'Laptop', sales: 2000 },
  { region: 'West', product: 'Phone', sales: 800 },
]

function onCellClick(cell) {
  console.log('Clicked:', cell)
}
</script>

Composable 用法

<template>
  <div ref="container"></div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { usePivotTable } from '@composy/pivot-table-vue'

const container = ref<HTMLElement | null>(null)
const { create, result, setSort, setTheme, refresh, destroy } = usePivotTable()

onMounted(() => {
  if (container.value) {
    create(container.value, {
      data: [...],
      rows: ['region'],
      cols: ['product'],
      values: [{ field: 'sales', aggregator: 'sum' }],
    })
  }
})
</script>

Plugin 注册

import { PivotTablePlugin } from '@composy/pivot-table-vue'

app.use(PivotTablePlugin)
// 现在可以全局使用 <PivotTable />

Props

| Prop | 类型 | 默认值 | 说明 | |------|------|--------|------| | data | Record<string, unknown>[] | - | 数据源 | | rows | (string \| FieldConfig)[] | - | 行字段 | | cols | (string \| FieldConfig)[] | - | 列字段 | | values | (string \| ValueFieldConfig)[] | - | 值字段 | | aggregator | AggregatorType | 'sum' | 默认聚合类型 | | theme | 'light' \| 'dark' \| 'auto' | 'light' | 主题模式 | | showRowTotals | boolean | true | 显示行合计 | | showColTotals | boolean | true | 显示列合计 | | sortable | boolean | false | 启用排序 | | sort | SortConfig | - | 排序配置 | | filters | FilterConfig[] | - | 过滤配置 | | striped | boolean | true | 斑马纹 | | loading | boolean | false | 加载状态 | | emptyText | string | 'No data' | 空态文本 | | valueFormatter | (value: number \| null) => string | - | 全局值格式化 |

Events

| 事件 | 参数 | 说明 | |------|------|------| | cell-click | CellClickInfo | 单元格点击 | | cell-hover | CellHoverInfo | 单元格悬停 | | cell-hover-end | - | 悬停离开 | | sort | SortConfig | 排序变化 |

Expose

组件实例暴露以下方法:

instance、result、setData、setTheme、setSort、setFilters、setLoading、refresh

构建产物

| 目录 | 格式 | 入口 | |------|------|------| | dist/ | UMD | dist/index.js / dist/index.min.js | | es/ | ESM | es/index.js | | esm/ | ESM | esm/index.js | | lib/ | CJS | lib/index.cjs |

验证命令

pnpm run type-check    # 类型检查
pnpm run build         # 构建
pnpm run lint:check    # Lint 检查