@brftech/filex-react

中文文档
0.59.0发布于 2026/11/07MITTypeScriptESM + CJS构建来源已验证近 30 天下载 2838

filex React adapter - wraps for React idiom (props + camelCase event handlers)

原始使用文档
文档目录6 节
  1. Install
  2. Use
  3. Styles
  4. Bundler note
  5. Build
  6. License
filex logo

@brftech/filex-react

React adapter for the filex file manager. Thin wrapper around <filex-explorer> (the @brftech/filex Web Component) - gives you proper React props and camelCased event handlers via @lit/react's createComponent.

⚠ This package wraps the explorer only. filex's other surface - the connections panel, where storages are added and the credentials for reaching the server over S3/SFTP/FTPS/NFS/WebDAV are minted - ships as <filex-connections> in @brftech/filex and is a plain custom element: render it directly in JSX and set config on the ref, exactly as you would any non-React element.

Install

npm i @brftech/filex-react react react-dom

⚠ @brftech/filex-react 0.55 needs a filex 0.55 server. Which files open for editing (edit_kinds), the input limits (limits) and the version line (release, commit, built) come from the server's /api/files/capabilities; the package keeps no list of its own to fall back on, so against an older server nothing is offered Edit and nothing opens as an office document. Update the server with the package (API.md).

⚠ An app that prints (ui.print, filex 0.55) prints from filex's own print page, which the explorer frames in your page. Only filex, its desktop app and the server's FILEX_FRAME_ANCESTORS may frame that page, so on another site list your page's origin there - otherwise the app is told printing is unavailable (CONFIGURATION.md → Security headers and framing).

Use

import { FileManager } from '@brftech/filex-react';

export function App() {
  return (
    <FileManager
      config={{
        apiBase: 'https://files.example.com',
        auth: { kind: 'bearer', token: '<jwt>' },
        locale: 'tr',
        theme: 'auto',
        // The navigation panel (the "+ New" menu · Home / Shared with me /
        // My shares / Recent / Starred / Trash · your tags, personal and team ·
        // an Apps section · storages) and how much of the
        // explorer to draw. Both are ordinary config keys - there is no
        // React-specific switch for either.
        sideNav: true,
        connections: true,
        // How much of the explorer to put on screen - a reduction, and only
        // that. Two values: 'standard' (default) and 'simple' (one pane,
        // list/grid only, no tab strip, no split pane). Anything else resolves
        // to 'standard' with one console line naming it - the 'drive' profile
        // was removed after v0.40.0; pass 'simple' instead. It does NOT decide
        // the look: the "+ New" menu, the header search field with its ⌘K hint,
        // the filter row, the Folders/Files sections and Details/Activity are
        // what every embed draws now, with no string passed.
        uiProfile: 'simple',
      }}
      onError={(e) => console.error(e.detail[0].message)}
      onShareCreated={(e) => navigator.clipboard.writeText(e.detail[0].url)}
      onFileOpened={(e) => console.log('opened', e.detail[0].basename)}
      onUploadProgress={(e) => console.log(e.detail[0].percent + '%')}
      onSelectionChange={(e) => console.log(e.detail[0].length, 'selected')}
    />
  );
}

The config prop accepts the full ExplorerConfig (re-exported from @brftech/filex-core for convenience). Event handlers receive native CustomEvents, and ⚠ the payload is event.detail[0]: the underlying custom element dispatches each emit with detail set to the emit's argument list, so event.detail.url is undefined. The exported Filex*Detail types describe that first element.

Styles

There is no CSS import. The snippet above is the whole of it: this package has no stylesheet of its own and you do not need one from anywhere else.

@brftech/filex-react wraps the <filex-explorer> element from @brftech/filex, whose bundle carries the explorer's stylesheet inside the JavaScript and appends it to <head> once, the first time an element mounts. The sheet is @brftech/filex-core's, byte for byte, so a React page and a Vue page render the same explorer - the Vue wrapper is the only one that imports a style.css, because mounting an SFC runs no registration step that could inject it.

The look is the --fe-* custom properties. Set them on any scope above the component - :root, a wrapper div - and the explorer follows:

:root {
  --fe-primary: #2b7a41;
  --fe-radius: 10px;
}

Light/dark follows config.theme ('light' / 'dark' / 'auto', and auto reads the host's prefers-color-scheme). The shipped palettes are in docs/INTEGRATION.md - and an operator's own themes, composed on the admin Appearance screen, arrive through the same --fe-* tokens, so an embed wears the instance's colours without being told about them.

⚠ The product mark in the top bar comes from config.brand ({ name, markUrl }), not from a slot. A host that mounts a custom element cannot fill a slot inside it - that is a Vue custom-element limitation, not an oversight - so the config entry is the door.

Bundler note

The rich viewers (Monaco, Mermaid, epub, xlsx, CodeMirror, …) are optional and reached through dynamic imports that are caught, so a build without them simply shows the plain viewer. A bundler, however, refuses to resolve an import it cannot find, so vite build stops with Rollup failed to resolve import "monaco-editor" unless you either install the ones you want or tell it they are external:

// vite.config.js
export default {
  build: {
    rollupOptions: {
      external: [
        'monaco-editor', 'jszip', 'mermaid', 'epubjs', 'xlsx',
        '@google/model-viewer', 'codemirror', /^@codemirror\//,
      ],
    },
  },
};

Build

pnpm build      # tsc check + vite lib build → dist/filex-react.{js,cjs}

License

MIT

版本与发布记录

@brftech/filex-react 共发布 149 个版本,首次发布于 2026/07/05;过去 12 个月发布了 149 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.59.0latest2026/11/071 天前
0.58.22026/11/062 天前
0.58.02026/11/044 天前
0.57.72026/10/318 天前
0.57.62026/10/2712 天前
0.57.52026/10/2118 天前

关于 @brftech/filex-react 的常见问题

@brftech/filex-react 是什么?

filex React adapter - wraps for React idiom (props + camelCase event handlers)

如何安装 @brftech/filex-react?

在项目目录运行 npm install @brftech/filex-react,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.0.0 || ^19.0.0)、react-dom(^18.0.0 || ^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@brftech/filex-react 支持 TypeScript 吗?

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

@brftech/filex-react 支持 ESM 还是 CommonJS?

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

@brftech/filex-react 可以商用吗?

@brftech/filex-react 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@brftech/filex-react 的下载量有多少?

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

@brftech/filex-react 还在维护吗?

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