@bytetrade/files-picker-wc

中文文档
0.2.9发布于 2026/10/28GPL-3.0-or-laterTypeScriptESM + CJS零依赖近 30 天下载 1820

Olares folder picker Web Component

原始使用文档
文档目录8 节
  1. Two build entries
  2. Attributes
  3. Events
  4. Required: inject FilesBrowserClient
  5. Two layouts
  6. Icon font
  7. i18n
  8. Peer vs second Vue / files-core copy

@bytetrade/files-picker-wc

Self-contained <olares-folder-picker> custom element for picking a folder (or files) from an Olares Files tree. Built with Vue 3 custom elements and a Shadow DOM; styles are injected via the styles option so any host bundler works.

Two build entries

ImportBundleWhen to use
@bytetrade/files-picker-wcPeer build (~58 kB). Externalises vue and @bytetrade/files-core.Hosts that already own those packages (the Quasar app). Required so configureFiles({ browser }) and the picker's getFilesConfig().browser share one files-core singleton.
@bytetrade/files-picker-wc/standaloneFully self-contained (~323 kB).Hosts without Vue / files-core (e.g. React).

Run these from the repository root; files-core must be built first because the peer build compiles against its output.

npm install
npm run build     # files-core, then this package's peer + standalone bundles
npm run smoke     # jsdom checklist against the standalone artefact
npm run lint

Attributes

AttributePropDefaultNotes
originsoriginsDrive,Sync,External,Cache,Data,CommonComma-separated DriveType values
pick-typepickTypeFOLDERFOLDER or FILE
icon-baseiconBase/imgBase URL for file/folder SVG artwork
localelocaleen-USHot-updates labels when changed
themethemelightlight / dark (data-theme)
mobile-root-titlemobileRootTitlecurrent pick titleHost-localized mobile storage-page title
mobile-root-labelmobileRootLabelemptyHost-localized heading above storage locations
mobile-sync-titlemobileSyncTitleSync group labelHost-localized library-page title
mobilemobileautoauto picks the layout from a max-width: 720px query; true / false force the mobile page stack or the desktop dialog. See MOBILE_SHARD.md
master-nodemasterNodefalseRestricts to master-node drives
base-urlbaseUrl(config)Optional override
—token(config)Property, not attribute
—transport(config)Property, not attribute

Events

EventDetail
pickFOLDER: a FilePath (Vue may wrap as [FilePath]). FILE: FileItem[].
cancelnone

Required: inject FilesBrowserClient

The element never talks to the Files HTTP API itself. Before opening it, the host must configure files-core:

import { configureFiles } from '@bytetrade/files-core/base';
import { registerOlaresFolderPicker } from '@bytetrade/files-picker-wc';

configureFiles({ browser: myClient /* + token, transport, … */ });
registerOlaresFolderPicker();

const el = document.createElement('olares-folder-picker');
el.setAttribute('pick-type', 'FOLDER');
el.setAttribute('locale', 'zh-CN');
el.addEventListener('pick', e => {
  /* … */
});
document.body.appendChild(el);

If browser is missing, the picker boots empty (boot() returns early).

Two layouts

The desktop layout is a resizable dialog (side menu + breadcrumb + sortable columns). The mobile layout is a full-screen bottom sheet with a page stack: the drive list first, then the listing. A tap opens folders there (touch has no dblclick), so only files toggle selection. Choose with mobile.

Icon font

Icons are Material Symbols ligatures rendered through a document-level @font-face that aliases whatever the host has installed (local(...)). Hosts that subset their icon font must keep the ligatures the picker uses — close, arrow_back, arrow_forward, chevron_left, keyboard_arrow_right, check_circle — or those glyphs render as raw text. A subset script that only scans the host's own sources will not see them, since they live in this package's bundle. In TermiPass they are listed in packages/app/scripts/icons/icons.allowlist.txt.

i18n

Standalone catalogs cover en and zh only. Inside the Quasar app, setFilesI18n forwards to the app translator so every language works.

Peer vs second Vue / files-core copy

Do not ship the peer build into a host that resolves a different @bytetrade/files-core than the one configureFiles was called on — the picker will see browser === undefined. The TermiPass Quasar app consumes the peer entry and installs @bytetrade/files-core itself, so both resolve to one copy; external React apps should use ./standalone and call configureFiles from that same module graph (re-exported from the package).

版本与发布记录

@bytetrade/files-picker-wc 共发布 14 个版本,首次发布于 2026/08/21;过去 12 个月发布了 14 个版本。

版本发布日期距今
0.2.9latest2026/10/2812 天前
0.2.82026/10/2713 天前
0.2.72026/10/2713 天前
0.2.62026/10/2713 天前
0.2.52026/10/2713 天前
0.2.42026/10/2713 天前

关于 @bytetrade/files-picker-wc 的常见问题

@bytetrade/files-picker-wc 是什么?

Olares folder picker Web Component

如何安装 @bytetrade/files-picker-wc?

在项目目录运行 npm install @bytetrade/files-picker-wc,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(^3.5.0)、@bytetrade/files-core(^0.2.9)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bytetrade/files-picker-wc 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bytetrade/files-picker-wc 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bytetrade/files-picker-wc 可以商用吗?

@bytetrade/files-picker-wc 使用 GPL-3.0-or-later 许可。强 Copyleft:分发包含该代码的软件时,整个作品需以 GPL-3.0 兼容许可开源,并附带专利与反锁定条款。仅内部使用不触发此义务。以上为概括,不构成法律意见,请以许可原文为准。

@bytetrade/files-picker-wc 的下载量有多少?

根据 npm 官方下载统计,@bytetrade/files-picker-wc 在 2026/10/09 – 2026/11/07 这 30 天内被下载 1,820 次,日均约 61 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bytetrade/files-picker-wc 还在维护吗?

最新版本 0.2.9 发布于 2026/10/28(12 天前);至今共发布 14 个版本,其中过去 12 个月发布了 14 个;首次发布于 2026/08/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。