@flow-industries/ui

中文文档
0.27.0发布于 2026/10/18MITES Module构建来源已验证近 30 天下载 2792

Shared design system and component library for Flow applications.

原始使用文档
文档目录8 节
  1. Installation
  2. Documentation
  3. Development
  4. Visual regression
  5. Accessibility
  6. License
  7. Practice sessions
  8. Packed package compatibility

Flow UI

Shared design system and component library for Flow applications.

Ships raw TypeScript source — no build step. Your Vite + Tailwind pipeline compiles it.

Installation

bun add @flow-industries/ui

Documentation

Full documentation at docs.flow.industries/en/ui.

Development

bun run dev   # landing page at localhost:5173

Visual regression

CI screenshots the showcase (#design, #showcases, #components in light and dark) against baselines committed under tests/visual.spec.ts-snapshots/ and fails on any diff.

bun run build && bun run test   # compare against baselines (Linux only)
./scripts/update-snapshots.sh   # re-render baselines after an intended visual change (Docker)

Baselines are rendered on Linux inside the pinned Playwright image — a bare macOS run diffs against them spuriously, so always update through the script (or grab the visual-diffs artifact from a failed CI run to inspect changes).

Accessibility

CI also runs axe (tests/a11y.spec.ts) over the same pages and themes, plus each overlay in its open state, failing on serious/critical violations. Genuine findings get fixed or filed against the UI-3 audit — see knownViolations in the spec for the tracked exceptions; allowlistedRules is reserved for documented false positives.

bun run build && bunx playwright test tests/a11y.spec.ts

License

MIT

Practice sessions

@flow-industries/ui/focus is an opt-in entry point for FocusProvider, FocusPanel, StudySubjectPicker, and the associated hooks and types. Install @flow-industries/id version 0.22.0 or newer alongside the UI package to use it. The SDK peer is optional for applications using only other UI components.

import { createFocusApi } from "@flow-industries/id/focus";
import { FocusPanel, FocusProvider, useFocus } from "@flow-industries/ui/focus";

function Practice() {
  const focus = useFocus();
  return <FocusPanel focus={focus} surface="web" />;
}

// Keep this API instance stable; credentials and surface belong to the host.
const api = createFocusApi(authHost, getToken, "web");

<FocusProvider api={api} viewerId={viewerId}>
  <Practice />
</FocusProvider>;

Pass a stable authenticated account ID as viewerId, or null for an inert provider. The host retains its guest, disabled-account, and embedded-surface policy: omit the provider/panel wherever practice must be excluded. Account changes clear session and subject state and discard old asynchronous responses. The provider restores active sessions on mount and refreshes when the document becomes visible. Outside a provider, hooks return an inert value.

FocusPanel accepts an explicit focus value, an optional managementLink, and text as an injected FocusText translator. Use text={createFocusText(locale, messages)} for locale and message overrides. The controlled StudySubjectPicker accepts catalog/subjects, busy/error state, and pick/create callbacks; the host owns requests when using it alone. Arrow keys navigate, Enter selects, and Escape clears search or returns from a category. Private subject labels are marked data-user-content and isolated for bidirectional text.

The showcase at /#focus provides account, delay, error, reload, and theme controls with local fixture data. Run bun run build then bunx playwright test tests/focus.spec.ts for recovery, privacy, keyboard and failure checks.

Packed package compatibility

bun run test:package packs the same src allowlist installed from npm and installs it into disposable React 19.0.0 and 19.2.3 consumers with React Router 7.8.2, Vite 7.2.7 and Tailwind 4.1.18. Each consumer renders on the server, builds browser assets, then hydrates in Chromium and exercises keyboard focus, select/input rendering, button interaction and emitted CSS tokens. Install the browser first with bunx playwright install chromium.

The check removes the component export and token stylesheet in the installed copy and requires each broken build to fail, then restores the files and repeats the successful browser check. PR CI and the publishing workflow both require this gate. A new supported consumer configuration belongs in this matrix before a release depends on it; incompatible changes require a coordinated package version and consumer update. These checks use package imports, never source aliases.

版本与发布记录

@flow-industries/ui 共发布 40 个版本,首次发布于 2026/04/11;过去 12 个月发布了 40 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.27.0latest2026/10/1829 天前
0.26.22026/10/141 个月前
0.26.12026/10/141 个月前
0.26.02026/10/141 个月前
0.25.52026/10/131 个月前
0.25.42026/10/131 个月前

关于 @flow-industries/ui 的常见问题

@flow-industries/ui 是什么?

Shared design system and component library for Flow applications.

如何安装 @flow-industries/ui?

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

@flow-industries/ui 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/flow-industries__ui 是否存在。

@flow-industries/ui 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@flow-industries/ui 可以商用吗?

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

@flow-industries/ui 的下载量有多少?

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

@flow-industries/ui 还在维护吗?

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