@21stware/rpui 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # RPUI Web Components Reference for LLMs
2
2
 
3
- RPUI means Readable Prototype UI. It is a static prototype specification and rendering runtime implemented with native Web Components.
3
+ RPUI means Rapid Prototype UI. It is a static prototype specification and rendering runtime implemented with native Web Components.
4
4
 
5
5
  A generated prototype imports one file only:
6
6
 
@@ -10,6 +10,8 @@ A generated prototype imports one file only:
10
10
 
11
11
  `dist/rpui.js` registers all custom elements and injects runtime CSS plus Lucide-style inline SVG icons. Do not import external CSS, image CDNs, icon CDNs, or UI frameworks.
12
12
 
13
+ ARIA note: component states (checked / expanded / selected / disabled / current / pressed) follow the structure that the W3C ARIA Authoring Practices expect, so annotations can describe accessibility intent precisely. RPUI is static and does not emit runtime `role` / `aria-*` attributes — treat ARIA as a reference for which states to expose and document, not as runtime behavior.
14
+
13
15
  ## Core model
14
16
 
15
17
  RPUI has two layers:
@@ -59,6 +61,20 @@ Every `data-pin="N"` must have a matching top-level annotation:
59
61
 
60
62
  RPUI renders water-drop pins automatically. Never write pin DOM manually.
61
63
 
64
+ ## Section addressing, deep links, and enum numbering
65
+
66
+ The runtime makes the canvas navigable. Authors do not write any of these attributes — they are generated:
67
+
68
+ - Every annotation gets a `data-rp-section` path. Top-level annotations use their `id` (e.g. `3`); nested annotations use the parent path plus their 1-based position among annotation siblings (e.g. `3-2`, `3-2-1`). This supports up to 3–5 levels of nesting.
69
+ - Every annotation renders a marker showing its **local index** (the last path segment): top-level = blue water-drop with the id; nested depth 1 = purple circle; nested depth ≥2 = green triangle. A nested annotation at `3-2` is marked `2`, at `3-2-1` is marked `1` — local to its parent, not the full path.
70
+ - To explain a UI slice that is rendered inside an annotation, nest another `<rp-annotation>` around/after it. The nested annotation gets its own numbered circle/triangle marker and its body indents one level: `main view → ⬤ annotation 3 → UI slice → ① nested annotation → detail`.
71
+ - Clicking a pin in the main snapshot, or clicking an annotation title, updates the URL to `?section=<path>` and scrolls/focuses the matching annotation with a dashed-outline highlight.
72
+ - Loading a URL with `?section=3-2-1` focuses that nested annotation on load (reverse deep link).
73
+ - Each `<rp-enum-item>` is auto-numbered with a black square index badge (1, 2, 3…), so annotation prose can reference "state 2" unambiguously.
74
+
75
+ Keep annotation and enum-item sibling order intentional and stable: the generated addresses depend on DOM order.
76
+
77
+
62
78
  ## Layout and state rules
63
79
 
64
80
  - RPUI is static. Do not create interactions.
@@ -71,7 +87,8 @@ RPUI renders water-drop pins automatically. Never write pin DOM manually.
71
87
  - The title/route/description and main snapshot stay visible on the left while the annotation pane scrolls independently on both axes.
72
88
  - Keep annotations compact and document-flow oriented. Do not stretch annotation content to full width.
73
89
  - Choose a device preset for new prototypes: `web` (1440px), `ipad` (834px), or `mobile` (390px). Presets use fixed width and auto height unless a numeric height is provided.
74
- - In the main snapshot, keep selects/dropdowns/popovers collapsed unless the page's primary representative state truly requires the overlay to be visible. Prefer showing expanded select/dropdown contents in annotation enums so they do not obscure the main layout.
90
+ - In the main snapshot, keep selects collapsed; show their expanded list in an annotation enum.
91
+ - Overlays and transient feedback — `rp-modal`, `rp-drawer`, `rp-dropdown`, `rp-popover`, `rp-tooltip`, `rp-toast` — are interaction results, not page regions. Do not place them in the main snapshot. Instead: pin the trigger element (button/row/field), state the trigger condition in the annotation, and render the overlay inside that annotation (usually in an `<rp-enum>`). Never stack mutually exclusive overlays/states side by side in the snapshot. A permanently docked side panel may stay open in the snapshot, but document its open/close trigger anyway.
75
92
  - Use `<rp-enum>` for state families, permission variants, hidden interaction results, and validation branches. Use `rp-enum-item description="..."` for a short clarification of a state.
76
93
 
77
94
  ## Snapshot primitives
@@ -102,7 +119,7 @@ RPUI renders water-drop pins automatically. Never write pin DOM manually.
102
119
 
103
120
  ### Data and content display
104
121
 
105
- - `<rp-table rows="6" columns="发件人,消息预览,时间,状态" has-checkbox has-action>` — generated static table.
122
+ - `<rp-table rows="6" columns="发件人,消息预览,时间,状态" has-checkbox has-action>` — generated static table. Cell text is sampled by the runtime from the column names, so you cannot specify exact cell values; describe precise data in the annotation instead.
106
123
  - `<rp-table-row state="default|selected|unread|highlighted|disabled">` — standalone row slice.
107
124
  - `<rp-bulk-action-bar count="3" actions="标为已读,归档,删除">`.
108
125
  - `<rp-empty label="暂无数据" description="..." has-action>`.
@@ -135,7 +152,90 @@ All form states are explicit through attributes; there is no runtime focus or in
135
152
 
136
153
  - `<rp-alert type="info|success|warning|error" title="..." message="..." closable>`.
137
154
  - `<rp-toast type="info|success|warning|error" title="..." message="..." closable>`.
155
+ - `<rp-banner type="info|success|warning|error" title="..." message="..." has-action closable>` — full-width page banner.
138
156
  - `<rp-progress value="40" kind="bar|circle" status="success|error">`.
157
+ - `<rp-skeleton shape="line|block|card|list|avatar">` — loading placeholder.
158
+ - `<rp-countdown value="02:45:18">` — time-remaining chip.
159
+ - `<rp-result status="success|error|empty" title="..." description="..." has-action>` — full-page result.
160
+
161
+ ### Data input (additional)
162
+
163
+ - `<rp-slider value="60" min="0" max="100" label="..." show-value>`.
164
+ - `<rp-range low="20" high="70" min="0" max="100">` — dual-thumb range.
165
+ - `<rp-number-input value="42">` — input with +/- steppers.
166
+ - `<rp-rating value="3" max="5">` — star rating.
167
+ - `<rp-pin-input length="4" value="12">` — OTP/PIN cells.
168
+ - `<rp-color-swatch value="#2563eb" label="...">`.
169
+ - `<rp-autocomplete value="..." placeholder="..." options="A,B,C" open>`.
170
+
171
+ ### Data display (additional)
172
+
173
+ - `<rp-tree>` + `<rp-tree-item label="..." icon="..." level="0" expanded|collapsed state="selected">`.
174
+ - `<rp-timeline>` + `<rp-timeline-item label="..." time="..." state="default|active|done|error">`.
175
+ - `<rp-calendar month="2026 年 6 月" selected="15">` — month grid.
176
+ - `<rp-kanban>` + `<rp-kanban-column title="..." count="3">` + `<rp-kanban-card label="..." tag="...">`.
177
+ - `<rp-code-block lang="ts" lines="5">` — code placeholder with line numbers.
178
+ - `<rp-diff rows="4">` — added/removed/context lines.
179
+ - `<rp-image-grid count="6" columns="3">`.
180
+ - `<rp-key-value>` + `<rp-kv-row label="..." value="...">` — description list.
181
+ - `<rp-accordion>` + `<rp-accordion-item label="..." expanded>`.
182
+ - `<rp-chip label="..." icon="..." closable>` — compact token.
183
+
184
+ ### Navigation & layout (additional)
185
+
186
+ - `<rp-segmented options="日,周,月" active="1">`.
187
+ - `<rp-menu>` + `<rp-menu-item label="..." icon="..." shortcut="⌘O" state="disabled">`.
188
+ - `<rp-context-menu items="复制,重命名,删除">`.
189
+ - `<rp-command-palette query="..." results="A,B,C">`.
190
+ - `<rp-toc items="概述,安装,用法">` — table of contents.
191
+ - `<rp-kbd keys="⌘,K">` — keyboard shortcut chips.
192
+ - `<rp-split-pane columns="1fr 1fr">`, `<rp-divider vertical>`, `<rp-spacer size="16">`.
193
+
194
+ ### Enterprise / SaaS
195
+
196
+ - `<rp-permission-gate reason="需管理员权限">…locked slot…</rp-permission-gate>`.
197
+ - `<rp-quota-bar label="API 调用" used="920" limit="1000">` — turns red at ≥90%.
198
+ - `<rp-api-key value="sk_live_••••3f9a">` — masked key with copy affordance.
199
+ - `<rp-audit-row actor="..." action="..." time="...">`.
200
+ - `<rp-workflow-node label="..." state="default|active|done|error">`.
201
+
202
+ ### iOS platform (`rp-ios-*`, use with device="mobile")
203
+
204
+ - `<rp-ios-navbar title="..." large back="返回" trailing="编辑">`.
205
+ - `<rp-ios-tabbar items="A,B,C" icons="home,search,user" active="0">`.
206
+ - `<rp-ios-list header="...">` + `<rp-ios-list-item label="..." detail="..." icon="..." chevron>`.
207
+ - `<rp-ios-action-sheet title="..." actions="A,B,C" destructive="删除">`.
208
+ - `<rp-ios-alert title="..." message="..." actions="取消,确定">`.
209
+ - `<rp-ios-switch label="...">`, `<rp-ios-segmented options="A,B" active="0">`.
210
+ - `<rp-ios-button label="..." variant="filled|tinted|plain">`, `<rp-ios-search>`, `<rp-ios-stepper>`.
211
+
212
+ ### macOS platform (`rp-macos-*`, use with device="web")
213
+
214
+ - `<rp-macos-window title="...">` — window chrome with traffic lights.
215
+ - `<rp-macos-menubar items="文件,编辑,显示">`, `<rp-macos-toolbar>`.
216
+ - `<rp-macos-sidebar>` + `<rp-macos-source-item label="..." icon="..." group state="selected">`.
217
+ - `<rp-macos-segmented options="A,B,C" active="0">`.
218
+ - `<rp-macos-popover title="...">`, `<rp-macos-sheet title="...">`.
219
+ - `<rp-macos-stepper>`, `<rp-macos-disclosure label="..." expanded>`.
220
+ - `<rp-macos-table columns="名称,大小" rows="5">` — sortable-header table look.
221
+
222
+ ### Agent / conversational UI
223
+
224
+ For chat, copilot, and agent prototypes:
225
+
226
+ - `<rp-chat>` — conversation container; wraps the message stream.
227
+ - `<rp-user-message text="..." initials="我">` — right-aligned user bubble (text attr or rich children).
228
+ - `<rp-assistant-message name="助手" text="...">` — left-aligned assistant message; children render as rich content (can contain tool-call/output/citation).
229
+ - `<rp-system-message text="...">` — centered system/context note.
230
+ - `<rp-tool-call name="search" state="running|done|error" args="...">` — tool/function call card with status.
231
+ - `<rp-agent-output kind="text|code|terminal" label="..." text="...">` — command/code/tool output block.
232
+ - `<rp-reasoning expanded>…</rp-reasoning>` — collapsible thinking/reasoning block.
233
+ - `<rp-message-actions actions="copy,retry,up,down,edit,share">` — per-message action buttons.
234
+ - `<rp-suggestions items="A,B,C">` — suggested reply / prompt chips.
235
+ - `<rp-typing>` — streaming typing indicator.
236
+ - `<rp-composer value="..." placeholder="..." state="idle|streaming">` — prompt input bar (send button becomes stop while streaming).
237
+ - `<rp-citation index="1" title="...">` — source reference chip.
238
+ - `<rp-token-usage used="1840" limit="8000">` — token/context usage meter.
139
239
 
140
240
  ## Icon rule
141
241
 
@@ -193,3 +293,6 @@ For each page, consider whether these states apply:
193
293
  </body>
194
294
  </html>
195
295
  ```
296
+
297
+ For a realistic high-complexity reference (9 top-level annotations, 3–5 levels of nesting, implementation-level annotation bodies, permission matrix, state machines, SLA boundaries), see `demo/golden.html`. Refer to `SKILL.md` for the recursive decomposition method, coverage-matrix technique, and complexity expectations.
298
+
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@21stware/rpui",
3
- "version": "0.1.0",
4
- "description": "Readable Prototype UI: static UI prototype canvas and snapshot primitives implemented as Web Components.",
3
+ "version": "0.2.1",
4
+ "description": "Rapid Prototype UI: static UI prototype canvas and snapshot primitives implemented as Web Components.",
5
5
  "type": "module",
6
6
  "main": "dist/rpui.js",
7
7
  "module": "dist/rpui.js",
@@ -13,14 +13,15 @@
13
13
  },
14
14
  "./dist/rpui.js": "./dist/rpui.js",
15
15
  "./llms.txt": "./llms.txt",
16
- "./skill.txt": "./skill.txt"
16
+ "./SKILL.md": "./SKILL.md"
17
17
  },
18
18
  "sideEffects": true,
19
19
  "files": [
20
20
  "dist",
21
21
  "llms.txt",
22
- "skill.txt",
23
- "README.md"
22
+ "SKILL.md",
23
+ "README.md",
24
+ "LICENSE"
24
25
  ],
25
26
  "scripts": {
26
27
  "dev": "vite --open /preview/",
@@ -38,7 +39,7 @@
38
39
  "snapshot",
39
40
  "llm"
40
41
  ],
41
- "license": "MIT",
42
+ "license": "UNLICENSED",
42
43
  "devDependencies": {
43
44
  "typescript": "^5.8.3",
44
45
  "vite": "^5.4.11"
package/skill.txt DELETED
@@ -1,143 +0,0 @@
1
- # RPUI Prototype Implementation Skill
2
-
3
- Use this skill when converting product requirements, screenshots, existing UI code, or design notes into a static RPUI prototype.
4
-
5
- ## Goal
6
-
7
- Create one readable, static, self-contained HTML prototype that fully exposes a product page's UI structure, interaction states, permissions, loading states, empty states, error states, validation states, and edge cases.
8
-
9
- RPUI does not simulate interaction. It lays out interaction results spatially so reviewers can understand the complete state space without clicking anything. Treat it like baking time-based UI behavior into a document-flow canvas.
10
-
11
- ## Required inputs
12
-
13
- Prefer these inputs, in priority order:
14
-
15
- 1. Product requirement or user story.
16
- 2. Screenshot or design draft.
17
- 3. Existing code with conditional rendering.
18
- 4. Permission matrix or role notes.
19
- 5. Known loading, empty, error, validation, and edge cases.
20
-
21
- If some inputs are missing, infer common SaaS/product UI states and make assumptions explicit in annotations.
22
-
23
- ## Output contract
24
-
25
- Output a complete HTML file that imports exactly one RPUI runtime file:
26
-
27
- ```html
28
- <script type="module" src="./dist/rpui.js"></script>
29
- ```
30
-
31
- The document must contain:
32
-
33
- 1. one `<rp-page>` root with `title`, `route`, and `description`,
34
- 2. exactly one `<rp-main-view>` containing the main page snapshot,
35
- 3. snapshot content built with `rp-*` primitives,
36
- 4. numbered `data-pin="N"` anchors on meaningful main-view regions,
37
- 5. matching top-level `<rp-annotation id="N" label="...">` blocks,
38
- 6. `<rp-enum>` and `<rp-enum-item>` blocks for conditional states and variants.
39
-
40
- ## Implementation steps
41
-
42
- 1. Identify the page route, page title, and one-sentence description.
43
- 2. Choose a device preset: `web` for desktop/admin pages, `ipad` for tablet layouts, or `mobile` for phone layouts. Prefer fixed-width, auto-height prototypes.
44
- 3. Choose the most complex representative main snapshot: loaded data, selected rows, expanded drawers/modals when they are central to the page, active validation, and role-specific controls when relevant.
45
- 4. Build the main snapshot inside `<rp-main-view device="web|ipad|mobile">` using only `rp-*` snapshot primitives, usually inside an `<rp-viewport device="web|ipad|mobile">`.
46
- 5. Add `data-pin="N"` to every meaningful UI region. Number pins from 1 without gaps.
47
- 6. For every `data-pin="N"`, create one top-level `<rp-annotation id="N" label="...">`. The runtime places top-level annotations in the right-side annotation pane.
48
- 7. Keep annotation text concise and specific. Avoid large prose blocks and card-like padding wrappers.
49
- 8. Use nested `<rp-annotation>` only when a rule belongs to a smaller sub-region.
50
- 9. Put repeated/conditional state families in `<rp-enum>`.
51
- 10. Use `<rp-enum-item label="..." description="...">` for every state: default, focus, filled, selected, disabled, empty, loading, error, permission-specific, and data-size variants. `description` is optional and should be short.
52
- 11. Validate that no interactive JavaScript, event attributes, external images, external CSS, or CDN icons are used.
53
-
54
- ## Authoring rules
55
-
56
- - Use `rp-*` tags for new work. `proto-*` and `snap-*` are compatibility aliases only.
57
- - Use `<rp-page>`, not arbitrary root containers.
58
- - Use `<rp-main-view>` once per prototype page.
59
- - Use `rp-*` tags for both the main snapshot and UI slices inside annotations.
60
- - Do not use direct `div`, `button`, `input`, `table`, or similar product UI HTML. Use RPUI primitives instead. Basic text and simple inline annotation markup are allowed.
61
- - Do not write CSS or JavaScript in the prototype unless implementing or extending RPUI itself.
62
- - Do not use `position:absolute` or `position:fixed` in snapshot content. RPUI owns pin positioning.
63
- - Do not hide important content behind interactions. Expand it into the annotation area with `<rp-enum>`.
64
- - Do not stretch annotation blocks to full width. The runtime provides a right-side annotation pane; keep annotation content compact inside it.
65
- - Keep select/dropdown/popover overlays collapsed in the main snapshot unless visibility is essential to the representative state. Put expanded overlay contents in annotation enums or local slices so the main layout remains readable.
66
- - Use `rp-enum-item description="..."` for short state notes, not long prose.
67
- - Prefer `device="web"`, `device="ipad"`, or `device="mobile"` over hand-tuned width/height values. Use explicit numeric `height` only when a fixed-height clipped viewport is intentional.
68
-
69
- ## State coverage checklist
70
-
71
- For every page, check whether these states apply:
72
-
73
- - Loaded with normal data.
74
- - Empty data.
75
- - Loading or skeleton/spinner.
76
- - Error or retry.
77
- - Search default, focus, filled, no result.
78
- - Filter collapsed and expanded.
79
- - Row default, selected, unread, highlighted, disabled.
80
- - Bulk selection off and on.
81
- - Pagination first, middle, last, no more pages.
82
- - Permission variants such as readonly, admin, owner, external collaborator.
83
- - Destructive action confirmation.
84
- - Validation default, filled, error, disabled.
85
- - Overlay states such as dropdown, popover, modal, drawer, tooltip.
86
- - Upload empty, has-file, uploading.
87
-
88
- ## Primitive selection guide
89
-
90
- Use the smallest primitive that communicates the requirement:
91
-
92
- - page shell: `rp-page`, `rp-main-view`, `rp-viewport`
93
- - layout: `rp-layout`, `rp-panel`, `rp-card`
94
- - navigation: `rp-navbar`, `rp-sidebar`, `rp-tabs`, `rp-breadcrumb`, `rp-pagination`, `rp-steps`
95
- - data: `rp-table`, `rp-table-row`, `rp-list`, `rp-list-item`, `rp-stat-card`, `rp-tag`, `rp-badge`, `rp-avatar`
96
- - forms: `rp-input`, `rp-search`, `rp-textarea`, `rp-select`, `rp-date-picker`, `rp-checkbox`, `rp-radio`, `rp-toggle`, `rp-form`, `rp-form-item`, `rp-upload`, `rp-button`
97
- - states: `rp-empty`, `rp-loading`, `rp-alert`, `rp-toast`, `rp-progress`
98
- - overlays: `rp-dropdown`, `rp-popover`, `rp-tooltip`, `rp-modal`, `rp-drawer`
99
-
100
- Refer to `llms.txt` for the complete component attributes.
101
-
102
- ## Minimal template
103
-
104
- ```html
105
- <!doctype html>
106
- <html lang="zh-CN">
107
- <head>
108
- <meta charset="UTF-8" />
109
- <script type="module" src="./dist/rpui.js"></script>
110
- </head>
111
- <body>
112
- <rp-page title="页面标题" route="/route" description="页面说明">
113
- <rp-main-view device="web" scale="0.65">
114
- <rp-viewport device="web">
115
- <!-- main snapshot -->
116
- </rp-viewport>
117
- </rp-main-view>
118
-
119
- <rp-annotation id="1" label="区域说明">
120
- 简短说明此区域的职责。
121
- <rp-enum>
122
- <rp-enum-item label="默认" description="正常可用的数据态。"><rp-empty label="示例"></rp-empty></rp-enum-item>
123
- <rp-enum-item label="加载中" description="首次进入或刷新时展示。"><rp-loading rows="3"></rp-loading></rp-enum-item>
124
- <rp-enum-item label="错误" description="服务端或网络异常时展示。"><rp-alert type="error" title="加载失败" message="请重试"></rp-alert></rp-enum-item>
125
- </rp-enum>
126
- </rp-annotation>
127
- </rp-page>
128
- </body>
129
- </html>
130
- ```
131
-
132
- ## Quality bar
133
-
134
- A good RPUI prototype can be reviewed by engineering, product, design, and QA without running the real application. QA should be able to derive test cases from annotations. Engineering should be able to derive conditional rendering requirements from enum items. Design should be able to see whether hidden states were missed.
135
-
136
- Before finishing, check:
137
-
138
- - pin numbers are continuous and all have matching annotations,
139
- - the main snapshot shows the most complex useful state,
140
- - hidden interaction results are expanded into enums,
141
- - role/permission differences are visible,
142
- - annotations are compact and document-flow oriented,
143
- - no forbidden direct product UI HTML, scripts, event handlers, or external resources are present.