@_linked/shape-ui

中文文档
2.9.5发布于 2026/11/02MITTypeScriptES Module构建来源已验证近 30 天下载 2444

UI driven by a shape: editors, a table over any shape's instances, a form derived from its properties, a read-only view and a relation picker — plus the read and write paths through the Linked Query DSL.

原始使用文档
文档目录4 节
  1. Where it sits
  2. The host
  3. Tests
  4. Why the name changed

@_linked/shape-ui

UI driven by a shape.

Each component takes a Shape and a property shape and renders a control for it — a text field, a select, a date picker, an avatar. It works on any shape, not a known one, which is the whole point: an application that adds a property gets an editor for it without writing one.

<TextfieldEditor of={person} property={givenName} />

Where it sits

LayerPackageKnows about
Design tokens@_linked/cssnothing
Headless components@_linked/primitivesthe DOM and the tokens
Data binding@_linked/reactshapes and queries; ships no components
Shape-driven UI@_linked/shape-uihow to render an arbitrary shape
Product surfacesapplicationsone product's domain vocabulary

Everything here renders a @_linked/primitives control and adds the shape binding. Nothing here knows about a specific product.

Consume this layer rather than rebuilding it. A product that needs a shape-driven form field extends what is here; growing a second implementation inside an application is how the same component ends up existing three times, and then drifting.

The host

The tables, forms and pickers ask a DataManagerHost for what depends on the application around them, supplied once with <DataManagerHostProvider host={host}> and read with useDataManagerHost(). A host names no project, branch or dataset: queries are routed by LinkedStorage.

MemberRequiredWhat it is for
resolveShape(iri)yesone shape's wire metadata, for display and for the shape a field or form uses
resolveCatalog()noevery shape's wire metadata; sh:class-only relations resolve among these
resolveShapeCatalog()nothe ShapeCatalog every query is built in (below)
dataRootfor createsthe base IRI new instances are minted under
searchInstances, createInstance, updateInstancenofilled in from the DSL when absent
readInstance, inlineCreate, navigate, pickingnohost-specific reads and flows

Which shapes a query resolves against. Without resolveShapeCatalog, the default search, create and update register the shape they resolve in core's global registry (registerRuntimeShapes), which suits an app with one set of shapes. A host that serves several projects, or several branches of one, returns a ShapeCatalog (@_linked/core) for its current scope instead:

import {ShapeCatalog} from '@_linked/core/utils/ShapeCatalog';

const host: DataManagerHost = {
  dataRoot,
  resolveShape: async (iri) => wires[iri],
  resolveCatalog: async () => wires,
  resolveShapeCatalog: async () => ShapeCatalog.from(wires, {name: `${project}#${branch}`}),
};

The provider asks for it once per host object (retrying a rejection with a backoff, like resolveCatalog). Every default then builds its query inside withShapeCatalog(catalog, …) and nothing is registered. A call made while the catalog loads waits for it; after it failed, the call rejects rather than fall back to the registry. A host for another scope must be a new object. useHostShapeCatalog() returns the loaded catalog, for the query functions a host calls itself: selectInstances, selectInstance, searchInstancesWithDsl, createInstanceWithDsl and updateInstanceWithDsl each take {catalog} as their last argument.

Inherited fields. A host whose wires list a shape's inherited property shapes next to its own can mark each inherited one with inheritedFrom: {id}, the IRI of the shape that declares it. AddInstanceForms and EditInstanceForms then name that shape under the field's label and in the "Add optional field" menu ("from Action"), by its label in allShapes or else the last segment of its IRI. inheritedFromName(property, shapes) gives the same name.

Tests

npm test

Jest, over src/**/*.test.ts and src/**/*.test.tsx; CI runs it on every PR.

Why the name changed

This package was @_linked/ui. That name said only "not backend" — the least informative label available for the layer most in need of one that states its contract. shape-ui says what it is.

版本与发布记录

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

版本发布日期距今
2.9.5latest2026/11/025 天前
2.9.42026/10/2810 天前
2.9.32026/10/2513 天前
2.9.22026/10/2513 天前
2.9.12026/10/2414 天前
2.9.02026/10/2414 天前

关于 @_linked/shape-ui 的常见问题

@_linked/shape-ui 是什么?

UI driven by a shape: editors, a table over any shape's instances, a form derived from its properties, a read-only view and a relation picker — plus the read and write paths through the Linked Query DSL.

如何安装 @_linked/shape-ui?

在项目目录运行 npm install @_linked/shape-ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18 || ^19)、@_linked/css(^0.3.0)、framer-motion(>=11)、@_linked/icons(^1.0.0)、@_linked/primitives(^1.2.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@_linked/shape-ui 支持 TypeScript 吗?

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

@_linked/shape-ui 支持 ESM 还是 CommonJS?

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

@_linked/shape-ui 可以商用吗?

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

@_linked/shape-ui 的下载量有多少?

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

@_linked/shape-ui 还在维护吗?

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