@ctrliq/quantic-components

中文文档
1.97.0发布于 2026/10/29TypeScriptES Module近 30 天下载 3877
原始使用文档
文档目录7 节
  1. Component manifest
  2. The docs tier
  3. Fields
  4. Copy rules
  5. Versioning
  6. Icons
  7. Recommended tools

Quantic components

Component manifest

The package publishes every documented component as static data at @ctrliq/quantic-components/meta.json, generated at build time from the static meta each component declares. It is plain JSON, with no runtime imports and no loader:

const manifest = require('@ctrliq/quantic-components/meta.json');
{
  "schemaVersion": 1,
  "generated": "2026-08-25T00:00:00.000Z",
  "components": [
    {
      "tag": "quantic-dialog",
      "description": "Modal overlay dialog with focus trap ...",
      "category": "feedback",
      "props": [
        {
          "name": "open",
          "description": "Whether the dialog is visible.",
          "type": "boolean",
          "default": "false"
        }
      ],
      "events": [{ "name": "after-close", "description": "Fired after the dialog closes ..." }],
      "slots": [{ "name": "trigger", "description": "Element that opens the dialog when clicked." }],
      "examples": ["<quantic-dialog> ... </quantic-dialog>"],
      "relatedTo": ["quantic-button"],
      "avoidWhen": [
        {
          "when": "the dialog only confirms a destructive action",
          "useInstead": "quantic-confirm-dialog"
        }
      ],
      "accessibility": {
        "providedByComponent": ["focus trap, restore on close, Escape to dismiss"],
        "requiredFromConsumer": ["a title, via quantic-dialog-title or aria-label"]
      },
      "subComponents": ["quantic-dialog-title", "quantic-dialog-actions"]
    }
  ]
}

Props, slots and events are arrays carrying their name, and empty fields are omitted. Nothing is filtered out: forwarded native events are included and flagged, so a consumer decides whether to care. Treat a missing meta.json as "this install predates the manifest" rather than an error.

The docs tier

meta.json is the whole manifest and too large to put in context, so the package also publishes a progressive-disclosure tier generated from it by scripts/gen-llms.ts:

ExportWhat it is
@ctrliq/quantic-components/llms.txtThe index: how to install, and one line per component
@ctrliq/quantic-components/llms/{category}-components.mdOne file per category
@ctrliq/quantic-components/llms/components/{tag}.mdone file per component, props, slots, events and examples

Read the index, then the category, then the component. Every file resolves from node_modules at the version the project installed, so no network call is involved and no server can serve a version that disagrees with the installed package.

The index carries the install and wiring steps, extracted from the marked region of docs/getting-started.md rather than restated, because naming the components correctly is useless without knowing what to install and which stylesheets to load.

Storybook copies the same bytes into its public/ to serve them at /llms.txt, /llms/** and /components.json. The package is the producer; the app is a consumer.

Fields

Everything except tag, description and category is optional and omitted when unset, so a reader has to treat absence as "not stated" rather than as a default.

FieldTypeWhat it carries
tagstringThe custom element name. The React wrapper name is its pascal case.
descriptionstringOne or more sentences. The first sentence alone is used in the generated indexes.
categoryenumaction, form, display, layout, feedback, navigation or data.
propsarrayEach with name, type, and optionally description, options, default, required, copyRule.
slotsarrayEach with name and description, and optionally required, copyRule. The default slot has name: "".
eventsarrayEach with name, and optionally description, detail, forwarded.
examplesstring[]Markup, extracted from the Storybook stories at build time rather than hand-written.
relatedTostring[]Neighbouring tags. Says they are related, not which to choose.
avoidWhenarrayWhen to reach for something else. Each entry has when, and useInstead when there is an alternative to name. useInstead holds a tag when the alternative is a component and prose when it is not, since the answer is sometimes a stylesheet.
accessibilityobjectprovidedByComponent is behaviour the component implements, so a consumer must not reimplement it. requiredFromConsumer is what it cannot supply for itself, such as an accessible name.
asciistringDiagram of the component's anatomy.
experimentalbooleanThe API can change or be removed in a minor. Absence means supported. See rules/promotion.md.
deprecatedobjectuse names the replacement, reason says why.
subComponentOfstringThe parent this element is anatomy of, set only when the child is inert alone.
subComponentsstring[]Derived from the children's subComponentOf, so the two can never disagree.

Copy rules

A prop or slot that holds user-facing text carries copyRule, a reference into the lexicon the manifest ships as its top-level copyRules:

{
  "copyRules": {
    "action-label": {
      "rule": "Verb phrase naming what happens, specific enough to act on without the surrounding text.",
      "good": ["Delete project", "Restart node"],
      "avoid": ["OK", "Yes", "Submit", "Continue"]
    }
  },
  "components": [
    {
      "tag": "quantic-confirm-dialog",
      "props": [{ "name": "confirmText", "type": "string", "copyRule": "action-label" }]
    }
  ]
}

The reference is what keeps the rules consistent. The wording rule for a placeholder is the same on six inputs, so it is stated once and pointed at six times rather than copied and left to drift. Rules are named after the job the text does rather than the component that carries it, which is why one placeholder rule serves all of them.

Ids are typed as CopyRuleId in src/shared/copy-rules.ts, so a component referencing a rule that does not exist is a compile error rather than a dangling pointer in the published data. A reader resolving an id it cannot find should say nothing rather than print the id.

copyRule is set only where getting the wording wrong is a real failure, which is labels, headings, messages and placeholders. Most props do not carry one. An ariaLabel prop never does: an accessible name is an accessibility requirement, so it belongs in accessibility.requiredFromConsumer.

Versioning

schemaVersion is bumped when an existing reader could break: a field removed or renamed, a type changed, or a meaning changed. Adding an optional field does not bump it, because a reader that ignores the field is unaffected, so tooling must tolerate keys it does not recognise rather than refusing the document. Refuse a schemaVersion you do not know.

Icons

Per-icon elements are registered with the rest of the library, so <quantic-icon-lucide-rocket> needs nothing beyond the package entry point:

import '@ctrliq/quantic-components/register';

@ctrliq/quantic-components/icons is the separate, opt-in entry for the name-based lookup, <quantic-icon name="Rocket">. It inlines every Lucide glyph so a runtime name can resolve, which is around 1 MB, and it is kept out of the package entry point for that reason. Prefer the per-icon element unless the name is genuinely only known at runtime.

(lit-plugin)[https://marketplace.visualstudio.com/items?itemName=runem.lit-plugin] (VS code)

版本与发布记录

@ctrliq/quantic-components 共发布 79 个版本,首次发布于 2026/06/02;过去 12 个月发布了 79 个版本。

版本发布日期距今
1.97.0latest2026/10/2913 天前
1.96.32026/10/2913 天前
1.96.22026/10/2418 天前
1.96.12026/10/2220 天前
1.96.02026/10/2120 天前
1.95.02026/10/1922 天前

关于 @ctrliq/quantic-components 的常见问题

如何安装 @ctrliq/quantic-components?

在项目目录运行 npm install @ctrliq/quantic-components,或使用 pnpm add / yarn add / bun add。

@ctrliq/quantic-components 支持 TypeScript 吗?

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

@ctrliq/quantic-components 支持 ESM 还是 CommonJS?

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

@ctrliq/quantic-components 可以商用吗?

@ctrliq/quantic-components 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@ctrliq/quantic-components 的下载量有多少?

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

@ctrliq/quantic-components 还在维护吗?

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