@graview/primitives

中文文档
0.2.5发布于 2026/11/16Elastic-2.0TypeScriptES Module构建来源已验证近 30 天下载 1万

The primitive set, the lenses, the workbench and the visual system.

原始使用文档

@graview/primitives

A rich primitive set, six lenses, the workbench and the visual system.

Primitives — Panel, Chip, Roster, Grid, Axis, Connector, Aggregate, Fields. Enough that a new node kind renders sensibly at all three fidelities before anyone writes a view for it.

Lenses — a timeline, a calendar, a coverage matrix, a board, a plan and a status board. Each binds ROLES to an app's own fields or kinds, so a lens written for one domain is reused by another without learning anything about it. All six are built from the public primitives, which makes them the worked example of the authoring API rather than privileged insiders. The board draws discs when every slot's code is three characters or fewer and tokens — a pill sized to the word, the occupants inside it — when any code is longer; arrange: "shelf" lays a board whose x and y are categories out as headed bands. The status board (columns) draws a choice field's values as columns, in their declared order, and moves a card — by the keyboard or a drag — only by an act the seat may run that sets that field: a named step such as "Book" to its own column, where its condition holds for that card, and otherwise an act told the value.

A coverage cell over a path selects what it joins — its row, its column and the records between (data-graview-joins) — and draws the crossing's lines to the row's name and the column's head.

One rule for what looks pressable. A capsule is a choice the reader can make, or a record's state badge, and nothing else is one: in a set of choices the chosen one wears it and the rest are words to press. The places (Places) are text tabs that scroll, the current one underlined, at every width. A name is never cut where it is the thing to read: a row wraps before it cuts its badge or progress, a drive-in's marquee says its showings by name, and what is cut on purpose carries its whole name as its title and accessible name.

Workbench — the parts of an interface that are not about the domain: what is selected and what can be done with it, whether the rules hold, what just happened and how to take it back, how to back out of a view. All derived from the schema, the invariants and the op log.

The app, said once — AppBar: one bar over every face (FR-131) — the brand's mark (AppMark, drawn as given, never an SVG that could act) and the app's name as the page's heading, the switch between the scene and the pages (faces, FR-137), the place you are on as one control that opens every place (barPlaces: the home, the Lists, the Pictures, FR-138; on the scene useScenePlaces: everything and each picture, FR-144), the places standing on the row where they fit, the rest under "More" (placesThatStand, FR-145), and three tools of one size: the Find a face puts in it (useBarFind), Standing and Profile. AppTitle draws the mark, the name and the line under it elsewhere; useFavicon is for a face that owns the page.

Visual system — themeCss(scheme, brand). Two schemes that are not inversions of each other: dark loses luminance, light loses contrast and gains haze. A brand supplies its own and graview check measures it. The sheet is three parts: themeBaseCss, what every face draws on; viewsCss, the blocks a view spec is drawn with, which each face that draws a view draws beside it; and sceneCss, the rules only the scene draws (the districts from altitude, the plots, the village, the billboards), which an embed's scene face draws beside it so a page on the pages face carries none of them.

Design language

Three layers, and a component reads only the middle one:

LayerWhereWhat it holds
The identity@graview/core (the design kit, revision 03)En Dash navy #001769 and turquoise #00E5B9, paper #F7F7F2, ink #18213A, muted #586174; Montserrat at 550, 450 and 600; the shared-plane symbol
The semantic tokensthemeCss writes them as custom propertiessurfaces (--graview-ground, -panel, -panel-muted, -panel-warning, -bar, -float), text (--graview-ink, -ink-muted, -ink-faint), interaction (--graview-accent, -accent-dim, -accent-ink, -edge, -edge-bright), state (--graview-warn, -good, -bad), type (--graview-font-body, -display, -mono, --graview-weight-display, -body, -label), shape (--graview-radius, -radius-sm, -pad, -pad-sm, -gap), depth (--graview-lift-low, -lift-high, --graview-layer-*) and the kit (--graview-kit-*)
The app's overridesthe app's brandname, logo, page icon, both schemes' tokens, faces and weights, radius and density, a hue per kind, the kit

The shipped schemes are built on the identity: paper, reading ink and navy in the light, a deep navy ground with the navy's hue made light in the dark. Neither paints a wash or a glow; hover firms an edge rather than glowing. Turquoise is not a token at all: it is the symbol's point, a fill that is never text (1.5:1 on paper; navy reads on it at 9.7:1), so nothing the framework draws depends on it. An app that declares its own brand keeps its own colors, faces and logo, and the framework never puts Graview's mark in it.

How the scene reads against any district's color: a kind's hue is the brand's (accents) or a stable hash, and only the hue: the lighting of a block's three faces and the plot under it is the scene's, so a block reads as a block on both grounds. Selection and the keyboard's place are drawn in the accent, as an outline set off from the block, never as a change of the block's own hue, so a selected block in a navy-ish district still reads as selected. A relation is told from another by its pattern, its end cap and its width as well as its color, and every district, block and relation carries its name in words, so nothing is said by color alone. Disabled is a dimmed control that cannot be pressed; empty, loading and refused are said in sentences.

The words are set in Montserrat when the host has it, and in the reader's system sans otherwise: the framework names the face and never fetches it. A host that wants it imports the optional copy once — import "@graview/primitives/montserrat.css", 32 KB of woff2, weights 400–700, Latin, under the SIL Open Font License (beside it in the package). GraviewMark is the symbol for a host drawing Graview's own identity — a signature, a hosting service's chrome — inline in the ink it stands in, the point in --graview-mark-point when set, decorative unless given a title, and the optical micro cut under 28 px.

版本与发布记录

@graview/primitives 共发布 77 个版本,首次发布于 2026/10/02;过去 12 个月发布了 77 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.2.5latest2026/11/16今天
0.2.42026/11/16今天
0.2.32026/11/151 天前
0.2.22026/11/152 天前
0.2.12026/11/152 天前
0.2.02026/11/134 天前

关于 @graview/primitives 的常见问题

@graview/primitives 是什么?

The primitive set, the lenses, the workbench and the visual system.

如何安装 @graview/primitives?

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

@graview/primitives 支持 TypeScript 吗?

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

@graview/primitives 支持 ESM 还是 CommonJS?

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

@graview/primitives 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.22.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@graview/primitives 可以商用吗?

@graview/primitives 使用 Elastic-2.0 许可。声明的许可为 Elastic-2.0,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@graview/primitives 的下载量有多少?

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

@graview/primitives 还在维护吗?

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