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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@baye/office-share

v0.5.4

Published

A React component library for office document sharing and folder management

Readme

Office Share

一个基于 React + TypeScript + Antd 的办公文档共享组件库,提供文件夹管理和文档操作功能。

特性

  • 🗂️ 文件夹管理: 提供文件夹选择、创建、移动等功能
  • 📄 文档操作: 支持文档的基本操作和管理
  • 🎨 美观UI: 基于 Antd 设计系统,提供一致的用户体验
  • 📱 响应式: 支持移动端和桌面端
  • 🔧 TypeScript: 完整的类型支持
  • 现代化: 使用最新的 React 18+ 和 Vite 构建

安装

npm install office-share
# 或
yarn add office-share
# 或
pnpm add office-share

使用方法

基础导入

ES模块(推荐):

import { FolderDialog, useFolderList } from '@baye/office-share';
import '@baye/office-share/styles';

CommonJS:

const { FolderDialog, useFolderList } = require('@baye/office-share');
// 注意:CSS需要通过构建工具或手动引入

重要提示:

  • ES模块格式自动包含CSS导入,推荐使用
  • CommonJS格式需要手动导入CSS文件:@baye/office-share/styles
  • 确保你的构建工具(Webpack、Vite等)支持CSS文件处理

文件夹对话框组件

import React, { useState } from 'react';
import { FolderDialog } from 'office-share';

const App = () => {
  const [visible, setVisible] = useState(false);
  const [selectedFolder, setSelectedFolder] = useState(null);

  return (
    <div>
      <button onClick={() => setVisible(true)}>
        选择文件夹
      </button>
      
      <FolderDialog
        visible={visible}
        onCancel={() => setVisible(false)}
        onOk={(folder) => {
          setSelectedFolder(folder);
          setVisible(false);
        }}
      />
    </div>
  );
};

使用 Hooks

import { useFolderList, useFolderMoveRecentFolder } from 'office-share';

const FolderComponent = () => {
  const { data: folders, loading } = useFolderList();
  const { moveToRecent } = useFolderMoveRecentFolder();

  return (
    <div>
      {loading ? (
        <div>加载中...</div>
      ) : (
        folders?.map(folder => (
          <div key={folder.id} onClick={() => moveToRecent(folder.id)}>
            {folder.name}
          </div>
        ))
      )}
    </div>
  );
};

API 文档

组件

FolderDialog

文件夹选择对话框组件。

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | visible | 是否显示对话框 | boolean | false | | onCancel | 取消回调 | () => void | - | | onOk | 确认回调 | (folder: any) => void | - |

Hooks

useFolderList()

获取文件夹列表的 Hook。

返回值:

  • data: 文件夹列表数据
  • loading: 加载状态
  • error: 错误信息

useFolderMoveRecentFolder()

移动文件夹到最近使用的 Hook。

返回值:

  • moveToRecent: 移动到最近使用的函数

工具函数

通用工具函数

  • 提供常用的工具函数,具体请查看源码

网络请求工具

  • 基于 axios 封装的请求工具

依赖要求

Peer Dependencies

以下依赖需要在你的项目中安装:

{
  "react": ">=18.0.0",
  "react-dom": ">=18.0.0",
  "antd": ">=5.0.0",
  "axios": ">=1.0.0",
  "ahooks": ">=3.0.0",
  "classnames": ">=2.0.0"
}

开发

# 克隆项目
git clone https://github.com/default_user/office-share.git

# 安装依赖
pnpm install

# 启动开发模式
pnpm dev

# 构建项目
pnpm build

# 运行示例
cd example
pnpm dev

示例项目

项目中包含一个完整的示例项目,位于 example/ 目录下,展示了如何使用这个组件库。

cd example
pnpm install
pnpm dev

构建和发布

# 清理构建目录
pnpm clean

# 构建项目
pnpm build

# 发布到 npm
npm publish

许可证

MIT © [default_user]

贡献

欢迎提交 Issue 和 Pull Request!

更新日志

0.1.0

  • 🎉 初始版本发布
  • ✨ 添加 FolderDialog 组件
  • ✨ 添加 useFolderList 和 useFolderMoveRecentFolder hooks
  • ✨ 添加工具函数和类型定义