@haiyue/ui 0.2.1 → 0.3.0

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.
Files changed (139) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/LICENSE +27 -0
  3. package/README.md +707 -5
  4. package/dist/adapters/web/controls.js +28 -5
  5. package/dist/adapters/web/renderer.js +11 -10
  6. package/dist/adapters/web/styles.d.ts +2 -3
  7. package/dist/adapters/web/styles.js +42 -18
  8. package/dist/alert.d.ts +39 -0
  9. package/dist/alert.js +144 -0
  10. package/dist/anchor.d.ts +60 -0
  11. package/dist/anchor.js +274 -0
  12. package/dist/auto-complete.d.ts +83 -0
  13. package/dist/auto-complete.js +267 -0
  14. package/dist/avatar.d.ts +45 -0
  15. package/dist/avatar.js +135 -0
  16. package/dist/badge.js +5 -5
  17. package/dist/border-beam.js +1 -1
  18. package/dist/breadcrumb.js +5 -5
  19. package/dist/button-group.js +8 -8
  20. package/dist/button.js +10 -10
  21. package/dist/card.d.ts +29 -0
  22. package/dist/card.js +101 -0
  23. package/dist/carousel.d.ts +92 -0
  24. package/dist/carousel.js +509 -0
  25. package/dist/cascader.js +12 -12
  26. package/dist/checkbox.d.ts +12 -0
  27. package/dist/checkbox.js +22 -6
  28. package/dist/collapse.d.ts +13 -0
  29. package/dist/collapse.js +100 -13
  30. package/dist/context-menu.js +3 -3
  31. package/dist/core/types.d.ts +22 -3
  32. package/dist/core/validation.js +9 -4
  33. package/dist/date-picker.js +13 -13
  34. package/dist/descriptions.d.ts +44 -0
  35. package/dist/descriptions.js +169 -0
  36. package/dist/dialog.js +11 -11
  37. package/dist/divider.js +2 -2
  38. package/dist/draggable.js +1 -1
  39. package/dist/drawer.js +12 -12
  40. package/dist/dropdown.js +3 -3
  41. package/dist/empty.d.ts +20 -0
  42. package/dist/empty.js +58 -0
  43. package/dist/expandable.js +4 -4
  44. package/dist/form-item.d.ts +60 -0
  45. package/dist/form-item.js +212 -0
  46. package/dist/form.d.ts +41 -0
  47. package/dist/form.js +154 -0
  48. package/dist/history-controls.js +5 -5
  49. package/dist/image-preview.d.ts +22 -0
  50. package/dist/image-preview.js +38 -0
  51. package/dist/image.d.ts +52 -0
  52. package/dist/image.js +152 -0
  53. package/dist/index.d.ts +56 -0
  54. package/dist/index.js +84 -0
  55. package/dist/input.d.ts +11 -0
  56. package/dist/input.js +29 -15
  57. package/dist/internal/anchored-popup.d.ts +19 -0
  58. package/dist/internal/anchored-popup.js +89 -0
  59. package/dist/internal/form-control.d.ts +22 -0
  60. package/dist/internal/form-control.js +52 -0
  61. package/dist/internal/image-viewer.d.ts +51 -0
  62. package/dist/internal/image-viewer.js +210 -0
  63. package/dist/internal/pagination.d.ts +35 -0
  64. package/dist/internal/pagination.js +169 -0
  65. package/dist/internal/popover-base.d.ts +87 -0
  66. package/dist/internal/popover-base.js +365 -0
  67. package/dist/internal/presentation.d.ts +2 -0
  68. package/dist/internal/presentation.js +28 -0
  69. package/dist/internal/qrcodegen.d.ts +94 -0
  70. package/dist/internal/qrcodegen.js +856 -0
  71. package/dist/masonry.d.ts +36 -0
  72. package/dist/masonry.js +171 -0
  73. package/dist/mentions.d.ts +115 -0
  74. package/dist/mentions.js +485 -0
  75. package/dist/menu-shared.d.ts +1 -1
  76. package/dist/menu-shared.js +3 -3
  77. package/dist/menu.d.ts +63 -0
  78. package/dist/menu.js +339 -0
  79. package/dist/modal.d.ts +73 -0
  80. package/dist/modal.js +361 -0
  81. package/dist/notification.js +9 -9
  82. package/dist/pagination.d.ts +34 -0
  83. package/dist/pagination.js +73 -0
  84. package/dist/popconfirm.d.ts +6 -0
  85. package/dist/popconfirm.js +7 -0
  86. package/dist/popover.d.ts +6 -0
  87. package/dist/popover.js +7 -0
  88. package/dist/portable/icons.d.ts +5 -0
  89. package/dist/portable/icons.js +24 -0
  90. package/dist/portable/index.d.ts +3 -0
  91. package/dist/portable/index.js +2 -0
  92. package/dist/portable/responsive.d.ts +20 -0
  93. package/dist/portable/responsive.js +15 -0
  94. package/dist/portable/theme.d.ts +6 -1
  95. package/dist/portable/theme.js +23 -3
  96. package/dist/progress.d.ts +30 -0
  97. package/dist/progress.js +102 -0
  98. package/dist/qr-code.d.ts +62 -0
  99. package/dist/qr-code.js +224 -0
  100. package/dist/radio.d.ts +10 -0
  101. package/dist/radio.js +18 -5
  102. package/dist/range.js +7 -7
  103. package/dist/rate.js +3 -3
  104. package/dist/resizable.js +4 -4
  105. package/dist/result.d.ts +22 -0
  106. package/dist/result.js +88 -0
  107. package/dist/ribbon.d.ts +19 -0
  108. package/dist/ribbon.js +106 -0
  109. package/dist/segmented.d.ts +39 -0
  110. package/dist/segmented.js +192 -0
  111. package/dist/select.d.ts +12 -0
  112. package/dist/select.js +31 -13
  113. package/dist/skeleton.js +10 -10
  114. package/dist/spin.d.ts +26 -0
  115. package/dist/spin.js +80 -0
  116. package/dist/steps.js +13 -13
  117. package/dist/switch.d.ts +44 -0
  118. package/dist/switch.js +104 -0
  119. package/dist/table.d.ts +0 -2
  120. package/dist/table.js +46 -87
  121. package/dist/tabs.js +7 -7
  122. package/dist/tag.js +8 -8
  123. package/dist/time-picker.js +10 -10
  124. package/dist/timeline.js +12 -12
  125. package/dist/toast.js +9 -9
  126. package/dist/tooltip.js +4 -4
  127. package/dist/tour.js +11 -11
  128. package/dist/tree-node.js +2 -2
  129. package/dist/tree-select.d.ts +94 -0
  130. package/dist/tree-select.js +398 -0
  131. package/dist/tree.js +6 -5
  132. package/dist/upload.d.ts +107 -0
  133. package/dist/upload.js +353 -0
  134. package/dist/virtual-keyboard.js +5 -5
  135. package/dist/virtual-list.js +4 -4
  136. package/dist/virtual-mouse.js +5 -5
  137. package/package.json +99 -1
  138. package/themes/haiyue-dark.css +51 -0
  139. package/themes/haiyue-light.css +51 -0
package/README.md CHANGED
@@ -48,6 +48,189 @@ defineHaiyueUI();
48
48
  Because `defineHaiyueUI()` references the complete component set, prefer focused subpaths in bundle-sensitive
49
49
  product entry points.
50
50
 
51
+ ## Alert, Anchor, and Segmented
52
+
53
+ The three components have isolated, side-effect-free entry points and are also included in the opt-in root registration:
54
+
55
+ ```ts
56
+ import { defineAlertComponents } from '@haiyue/ui/alert';
57
+ import { defineAnchorComponents } from '@haiyue/ui/anchor';
58
+ import { defineSegmentedComponents } from '@haiyue/ui/segmented';
59
+
60
+ defineAlertComponents();
61
+ defineAnchorComponents();
62
+ defineSegmentedComponents();
63
+ ```
64
+
65
+ `<hy-alert>` supports `success`, `info`, `warning`, and `error`, optional built-in/custom icons, message and description
66
+ content, an `action` slot, banner presentation, and cancelable `alert-close` dismissal. `<hy-anchor>` accepts nested
67
+ `items`, tracks `active-href` against the viewport or an assigned `scrollContainer`, and exposes offsets, vertical or
68
+ horizontal layout, smooth scrolling, `scrollToAnchor()`, and composed click/change events. `<hy-segmented>` accepts
69
+ string or object options, uses an accessible radiogroup with roving focus, skips disabled choices during arrow-key
70
+ navigation, and supports three sizes, full-width layout, icons, group disable, `select()`, and `value-change`.
71
+
72
+ ## Modal
73
+
74
+ Import `defineModalComponents` from `@haiyue/ui/modal` and register once. `HYModal` is also exported by the root
75
+ and included in `defineHaiyueUI()`. It provides default confirmation/cancel actions around a native modal
76
+ `<dialog>`, with top-layer rendering, background inertness, focus containment and return focus through shadow roots.
77
+ The existing Dialog entry remains available for surfaces with application-supplied footer actions.
78
+
79
+ ```html
80
+ <hy-modal id="publish" heading="Publish project" width="560" ok-text="Publish">
81
+ <p>Review the project before publishing.</p>
82
+ </hy-modal>
83
+ ```
84
+
85
+ Call `showModal()` / `close(reason?)`, or set the reflected boolean `open` property/attribute.
86
+ `heading` defaults to “Modal”; the `heading` slot overrides its content and the default slot supplies the body.
87
+ `width` defaults to 520 CSS pixels (240–2000), constrained to the viewport. `centered`, `closable`,
88
+ `mask-closable` / `maskClosable`, `keyboard` (Escape), and `show-footer` / `showFooter` all default to true;
89
+ set their attributes to `"false"` or properties to false to disable them independently.
90
+ `ok-text` / `okText` and `cancel-text` / `cancelText` default to “OK” and “Cancel”.
91
+ Use the `footer` slot for application-owned custom actions, replacing both default buttons.
92
+
93
+ Bubbling/composed events are `modal-open`, `modal-ok`, `modal-cancel` and `modal-close`.
94
+ The cancelable `modal-ok` and `modal-cancel` events carry `{ reason }`. Preventing either event keeps the modal open.
95
+ Close reasons are `ok`, `cancel`, `close-button`, `mask`, `escape` and `programmatic`; `close(reason)` also accepts
96
+ an application-specific string. `modal-close` fires once after an actual close, with `{ reason }`.
97
+ With `controlled`, default user actions only emit requests; the application updates `open` or calls `close()`.
98
+
99
+ ```js
100
+ publish.addEventListener('modal-ok', async event => {
101
+ event.preventDefault();
102
+ publish.confirmLoading = true;
103
+ try {
104
+ await saveProject();
105
+ publish.close('ok');
106
+ } finally {
107
+ publish.confirmLoading = false;
108
+ }
109
+ });
110
+ publish.showModal();
111
+ ```
112
+
113
+ `confirm-loading` / `confirmLoading` disables the default actions and user dismissal, shows a spinner and marks the
114
+ surface busy; application `close()` remains available. `confirm-disabled` / `confirmDisabled` only disables confirmation.
115
+ `destroy-on-hidden` / `destroyOnHidden` unmounts light DOM content while closed, retaining the same nodes, values and
116
+ listeners for reopening. It defaults to false. Disconnecting removes modality and scroll locks without emitting a
117
+ close event; a retained `open` attribute reopens on reconnection. Nested modals retain scroll locking until the last closes.
118
+
119
+ Style parts `panel`, `header`, `heading`, `body`, `footer`, `actions`, `ok-button`, `cancel-button`,
120
+ `close-button`, `spinner`. Tokens include `--hy-modal-width`, `--hy-modal-radius`, `--hy-modal-body-padding`,
121
+ `--hy-modal-duration`, `--hy-modal-bg-color`, `--hy-modal-mask-color`, `--hy-modal-mask-blur`, `--hy-modal-shadow-color`,
122
+ `--hy-modal-footer-bg-color` and `--hy-modal-button-radius`; colors inherit semantic theme tokens. Reduced-motion
123
+ preferences suppress the entrance and spinner animations. No sibling component import or automatic registration is needed.
124
+
125
+ ## QR Code
126
+
127
+ Import `defineQRCodeComponents` from `@haiyue/ui/qr-code` and call it once. The root registration path also includes
128
+ `<hy-qr-code>`. Values are encoded locally into SVG; no runtime dependency or remote QR generation service is used.
129
+
130
+ ```html
131
+ <hy-qr-code value="https://haiyuestudio.github.io/UI/" size="220"
132
+ icon="/brand.svg" icon-size="32" icon-margin="2" aria-label="Open Haiyue UI"></hy-qr-code>
133
+
134
+ <hy-qr-code value="https://haiyuestudio.github.io/UI/">
135
+ <img slot="icon" src="/brand.svg" alt="" />
136
+ </hy-qr-code>
137
+ ```
138
+
139
+ Set `value` to a URL or text (including UTF-8/Chinese/emoji). `size` defaults to 200 CSS pixels (64–2048).
140
+ `margin` is the quiet zone in modules (default/minimum 4, maximum 16).
141
+ `error-correction-level` / `errorCorrectionLevel` accepts `L`, `M`, `Q`, or `H`. Without an explicit level,
142
+ it defaults to `H` with an icon and `M` otherwise. An explicit level applies with or without an icon.
143
+ An `icon` image URL or content in the `icon` slot adds a center icon; the slot takes precedence over the URL.
144
+ `icon-size` / `iconSize` requests the content size in pixels (default 32), while `icon-margin` / `iconMargin`
145
+ sets its backing padding (default 2). The complete overlay is capped at 20% of the QR matrix width, including padding,
146
+ and scales with responsive sizing. Icon content is decorative and inert. A failed image leaves the plain QR visible.
147
+
148
+ `color` and `background-color` / `backgroundColor` customize the QR colors. The inherited tokens
149
+ `--hy-qr-code-color` and `--hy-qr-code-background-color` default to dark modules on white for both themes.
150
+ Other styling hooks are `--hy-qr-code-icon-radius`, `--hy-qr-code-radius` and parts `frame`, `code`,
151
+ `background`, `modules`, `icon`, `icon-image`, `message`. Keep sufficient contrast and verify your final payload,
152
+ size, colors and icon with the intended scanner; arbitrary custom styling can affect readability.
153
+
154
+ The read-only `status` is `empty`, `ready`, or `error`. Empty values and over-capacity payloads clear the previous code.
155
+ Bubbling, composed events are `qr-render` with `{ value, version, moduleCount, errorCorrectionLevel }` after encoding,
156
+ `qr-error` with `{ message }` on encoding failure, and `qr-icon-error` with `{ src }` on image failure.
157
+ SVG is decorative beneath a labelled image role; set `aria-label` to describe the QR's purpose.
158
+
159
+ The internal encoder is vendored from [Project Nayuki](https://www.nayuki.io/page/qr-code-generator-library),
160
+ upstream Git blob `c4191ac0b5f8a24d87fd9340ceaa2d3b07d0231a`, with its MIT notice retained in source and `LICENSE`.
161
+ Local edits only add an ES module export, strict indexed-access assertions and formatting. Independent decoding tests
162
+ use `jsqr` as a development-only dependency. Internal encoder symbols are excluded from the public component API.
163
+
164
+ ## Carousel
165
+
166
+ `@haiyue/ui/carousel` exports `HYCarousel`, `defineCarouselComponents()` and the associated `HYCarousel*` types.
167
+ Registration is explicit; panels are HTML elements in the default slot and stay mounted between changes.
168
+
169
+ ```html
170
+ <hy-carousel direction="horizontal" indicator-style="line" indicator-position="bottom"
171
+ autoplay interval="4000" draggable="true" loop="true" aria-label="Featured projects">
172
+ <article>First panel</article>
173
+ <article>Second panel</article>
174
+ <article>Third panel</article>
175
+ </hy-carousel>
176
+ ```
177
+
178
+ | Attribute / property | Default | Behavior |
179
+ | --- | --- | --- |
180
+ | `index` | `0` | Active panel, zero based |
181
+ | `direction` | `horizontal` | `horizontal` or `vertical`; horizontal supports RTL |
182
+ | `indicator-style` / `indicatorStyle` | `dot` | `dot`, `line`, `number` |
183
+ | `indicator-position` / `indicatorPosition` | `bottom` | `top`, `right`, `bottom`, `left` |
184
+ | `show-indicators` / `showIndicators` | `true` | Set `false` to hide indicators |
185
+ | `show-arrows` / `showArrows` | `true` | Set `false` to hide previous/next buttons |
186
+ | `autoplay` | `false` | Opt-in automatic rotation with a pause/start button |
187
+ | `interval` | `3000` | Milliseconds, normalized to 100–86,400,000 |
188
+ | `draggable` | `true` | Mouse/touch swipe; set `false` to disable |
189
+ | `loop` | `true` | Wrap at the ends; `false` clamps and stops autoplay at the last panel |
190
+
191
+ Use `next()`, `previous()`, `goTo(index)`, `play()` and `pause()` for imperative control.
192
+ The bubbling, composed `change` event includes `{ index, previousIndex, source }`, with sources
193
+ `api`, `indicator`, `arrow`, `keyboard`, `drag`, `autoplay` and `content`.
194
+ Inactive panels are inert and hidden from assistive technology. Arrow keys (matching direction), Home and End
195
+ navigate the focused viewport or indicators; input fields keep their editing keys. Hover temporarily pauses rotation;
196
+ keyboard focus pauses until explicitly resumed. Reduced-motion preferences suppress transitions and initial automatic
197
+ rotation; `play()` permits explicit rotation. Disconnecting releases timers, pointer listeners and animations and restores panel attributes/styles.
198
+
199
+ Customize `::part(indicators)`, `::part(indicator)`, `::part(indicator-active)`, `::part(indicator-content)`,
200
+ `::part(previous)`, `::part(next)`, `::part(playback)` and `::part(viewport)`.
201
+ Tokens include `--hy-carousel-height` (240px), `--hy-carousel-duration` (320ms), `--hy-carousel-indicator-size`,
202
+ `--hy-carousel-indicator-gap`, `--hy-carousel-indicator-offset`, `--hy-carousel-indicator-radius`,
203
+ `--hy-carousel-indicator-color` and `--hy-carousel-indicator-active-color`; other colors inherit semantic theme tokens.
204
+ For arbitrary content, set `indicatorRenderer = (index, active) => Node | string | null` (strings are plain text).
205
+ The component retains the native accessible indicator buttons and click/keyboard behavior around your content.
206
+ Panels should not override the component's positioning, dimensions, visibility or transform.
207
+
208
+ ## Masonry layout
209
+
210
+ Import `defineMasonryComponents` from `@haiyue/ui/masonry` and call it once to register `<hy-masonry>`.
211
+ Place HTML elements of varying heights in the default slot:
212
+
213
+ ```html
214
+ <hy-masonry min-column-width="240" gap="16" aria-label="Project gallery">
215
+ <article>First card…</article>
216
+ <article>Another card with more content…</article>
217
+ <article><img src="preview.jpg" alt="Project preview" style="width: 100%" /></article>
218
+ </hy-masonry>
219
+ ```
220
+
221
+ `columns` defaults to `0` (automatic); positive values request a fixed number of columns.
222
+ `min-column-width` (default `240`) controls automatic sizing; `gap` (default `16`) sets both gaps in CSS pixels.
223
+ Columns shrink to fit narrow containers. Each item goes into the shortest column, starting at the inline start,
224
+ including RTL layouts. DOM, screen-reader and keyboard order remain the original slot order.
225
+ Items keep their own content, theme and semantics; the component supplies positioning, border-box width and zero outer margins.
226
+ Use padding inside cards and avoid overriding item positioning/width. Text nodes and named slots are not layout items.
227
+
228
+ Container resizing, item resizing (including image loads), adding/removing items and toggling `hidden` automatically
229
+ schedule a layout. Call `refresh()` after changes outside those observations (for example, a stylesheet rule that
230
+ reveals a previously hidden item). `layout-change` bubbles across shadow roots with `{ columns, itemCount, height }`
231
+ after geometry changes; `itemCount` excludes hidden items. Style the transparent container with `::part(layout)`.
232
+ Observers and queued frames are released on disconnect, and internal item CSS properties are restored.
233
+
51
234
  ## Tag and toast
52
235
 
53
236
  Tags provide compact semantic labels with optional checked and close interactions. Toasts are an imperative,
@@ -116,7 +299,374 @@ button, or the application calls `search()`. Its detail contains `{ value, valid
116
299
  available. Style the `control`, `input`, `prefix`, `suffix`, and `search-button` parts or the
117
300
  `--hy-input-affix-*` and `--hy-input-search-*` tokens.
118
301
 
119
- ## Portable component semantics (M24 G03/G05, unreleased)
302
+ ## Mentions
303
+
304
+ ```ts
305
+ import { defineMentionsComponents } from '@haiyue/ui/mentions';
306
+ defineMentionsComponents();
307
+
308
+ const mentions = document.querySelector('hy-mentions');
309
+ mentions.options = [
310
+ { value: 'alice', label: 'Alice Chen' },
311
+ { value: 'bob', label: 'Bob Lin' },
312
+ { value: 'archived', label: 'Archived account', disabled: true },
313
+ ];
314
+ mentions.prefixes = ['@', '#'];
315
+ mentions.addEventListener('mention-select', event => console.log(event.detail));
316
+ ```
317
+
318
+ ```html
319
+ <hy-mentions placeholder="Type @ to mention someone" rows="3"
320
+ aria-label="Comment"></hy-mentions>
321
+ ```
322
+
323
+ `<hy-mentions>` uses a native multiline textarea. `value`, `placeholder`, `rows`, `disabled`, and
324
+ `readOnly` are properties; `readonly`, `required`, `maxlength`, and `name` are also forwarded attributes.
325
+ The default trigger is `@`; set `prefix` for a single trigger or `prefixes` for multiple triggers
326
+ (the `prefixes` attribute accepts a JSON string array). Triggers start at the beginning of the text,
327
+ after whitespace, or after `split`. The default `split` is one space; it is inserted after a selection.
328
+ Selecting a suggestion replaces the current token and preserves the surrounding text.
329
+
330
+ Suggestions match the option's value or label without case sensitivity. Set `filterOption` to a
331
+ `(text, option) => boolean` function to customize matching, or `false` for server-filtered results.
332
+ The bubbling, composed `search` event exposes `{ text, prefix }`; use it to fetch options and set
333
+ `loading` while waiting. Consumers own request cancellation and stale-response handling.
334
+ `notFoundContent` and `loadingText` customize the empty/loading messages. `placement` prefers `top`
335
+ or `bottom`, and the popup automatically fits the viewport. Arrow keys skip disabled options,
336
+ Enter selects, Shift+Enter inserts a newline, and Escape/Tab dismiss. IME composition keeps its
337
+ native editing behavior. `focus()` and `blur()` target the textarea.
338
+
339
+ `value-change` emits `{ value }` on user edits and selections, while `mention-select` emits
340
+ `{ value, option, prefix }` after a selection. Programmatic value updates do not emit change events.
341
+ The native composed `input` event is also available. Style the `textarea`, `panel`, `list`, `option`,
342
+ and `status` parts; colors inherit the semantic theme tokens. Popup dimensions use
343
+ `--hy-mentions-popup-min-width`, `--hy-mentions-popup-max-width`, `--hy-mentions-popup-max-height`,
344
+ and `--hy-mentions-z-index`. `open` is a read-only property reflecting popup visibility.
345
+
346
+ ## Switch, Progress, and Spin
347
+
348
+ ```ts
349
+ import { defineSwitchComponents } from '@haiyue/ui/switch';
350
+ import { defineProgressComponents } from '@haiyue/ui/progress';
351
+ import { defineSpinComponents } from '@haiyue/ui/spin';
352
+ defineSwitchComponents();
353
+ defineProgressComponents();
354
+ defineSpinComponents();
355
+ ```
356
+
357
+ ```html
358
+ <hy-switch name="autosave" label="Auto save" checked checked-text="On" unchecked-text="Off"></hy-switch>
359
+ <hy-progress percent="42" aria-label="Build progress"></hy-progress>
360
+ <hy-progress type="circle" percent="75" status="active"></hy-progress>
361
+ <hy-spin spinning="false" delay="200" tip="Loading preview"><div>Preview content</div></hy-spin>
362
+ ```
363
+
364
+ Switch has `checked`, `disabled`, `loading`, `size` (`small`/`default`), `value`, `name`, and `label`
365
+ properties. A default slot can supply its label. `checked-text`/`unchecked-text` customize the state text.
366
+ It uses a native checkbox with `role="switch"`; Space and Enter toggle it, while loading disables interaction.
367
+ User changes emit composed `checked-change` (`{ checked, value }`) and `change` events. Property updates
368
+ are silent. It participates in native forms, required validation, disabled fieldsets and reset.
369
+
370
+ Progress accepts `percent` (clamped to 0–100), `type` (`line`/`circle`), `status`
371
+ (`normal`/`active`/`success`/`exception`), `indeterminate`, `showInfo`, `strokeWidth`, and circle `size`.
372
+ The corresponding attributes are kebab-case. Indeterminate progress omits `aria-valuenow`.
373
+ Style `meter`, `trail`, `fill`, `circle` and `info` parts, or `--hy-progress-color`/`--hy-progress-trail-color`.
374
+
375
+ Spin is spinning by default; use `spinning="false"` or `.spinning = false` to stop it. `delay` in milliseconds
376
+ postpones the indicator (capped at 60 seconds), and `tip`/`size` (`small`/`default`/`large`) customize it.
377
+ With slotted content it displays an overlay and makes that content inert while loading, including during
378
+ the delay. Without content it is a standalone indicator. Owned timers are canceled on detach.
379
+ Both loading components respect reduced-motion preferences and inherit semantic theme colors.
380
+
381
+ ## Popover and Popconfirm
382
+
383
+ The independent `@haiyue/ui/popover` and `@haiyue/ui/popconfirm` entries expose
384
+ `definePopoverComponents()` and `definePopconfirmComponents()` respectively.
385
+
386
+ ```html
387
+ <hy-popover heading="Quick settings" placement="bottom-start">
388
+ <button slot="trigger">Settings</button>
389
+ <input aria-label="Preset name" />
390
+ </hy-popover>
391
+ <hy-popconfirm heading="Delete asset?" description="This removes the selected asset">
392
+ <button slot="trigger">Delete</button>
393
+ </hy-popconfirm>
394
+ ```
395
+
396
+ Both expose `open`, `disabled`, `heading`, `content`, `description`, `trigger`, `placement`, `show()` and
397
+ `hide()`. The `trigger` slot accepts a native button or a focusable custom control; the default slot supplies
398
+ interactive content, and the `heading` slot overrides the heading text. Triggers are `click` (default),
399
+ `hover`, `focus`, or `manual`. Hover delays use `show-delay`/`hide-delay` in milliseconds. Placement supports
400
+ top/bottom/left/right with optional `-start`/`-end`; popups flip and fit the viewport and use the native
401
+ popover top layer when available, escaping clipped ancestors. Escape, outside clicks and focus leaving
402
+ the surface close it; keyboard interaction inside remains available and closing restores owned focus.
403
+ `open-change` is composed and carries `{ open, reason }`. Disconnect releases listeners, timers and observers.
404
+
405
+ Popconfirm adds `okText`, `cancelText`, `confirmLoading`, `confirmDisabled`, `confirm()` and `cancel()`.
406
+ Its cancelable, composed `confirm`/`cancel` events carry `{ source: 'button' | 'api' }`. A prevented event
407
+ keeps the panel open; during `confirmLoading`, buttons, outside dismissal and Escape are blocked.
408
+
409
+ ```ts
410
+ popconfirm.addEventListener('confirm', async event => {
411
+ event.preventDefault();
412
+ popconfirm.confirmLoading = true;
413
+ try { await removeAsset(); popconfirm.hide(); }
414
+ finally { popconfirm.confirmLoading = false; }
415
+ });
416
+ ```
417
+
418
+ Style `trigger`, `panel`, `heading`, `description`, `content`, `footer`, `confirm`, and `cancel` parts.
419
+ `--hy-popover-width`, `--hy-popover-shadow` and `--hy-popover-z-index` customize the surface.
420
+
421
+ ## Form and Form Item
422
+
423
+ ```ts
424
+ import { defineFormComponents } from '@haiyue/ui/form';
425
+ import { defineFormItemComponents } from '@haiyue/ui/form-item';
426
+ import { defineInputComponents } from '@haiyue/ui/input';
427
+ defineFormComponents();
428
+ defineFormItemComponents();
429
+ defineInputComponents();
430
+ ```
431
+
432
+ ```html
433
+ <hy-form aria-label="Project settings">
434
+ <hy-form-item name="project" label="Project name" required help="At least 3 characters">
435
+ <hy-input></hy-input>
436
+ </hy-form-item>
437
+ <button type="submit">Save</button>
438
+ <button type="reset">Reset</button>
439
+ </hy-form>
440
+ ```
441
+
442
+ Form owns one real light-DOM `<form>` exposed as `formElement`. Children added to the host are moved into
443
+ that form, so native controls and form-associated custom controls share one owner. Do not nest forms.
444
+ `hy-input`, `hy-select`, `hy-checkbox`, `hy-radio`, `hy-mentions`, `hy-switch`, `hy-upload`,
445
+ `hy-auto-complete` and `hy-tree-select` participate
446
+ in native `FormData`, disabled fieldsets and reset, including inside an ordinary `<form>`. Other custom
447
+ components require an application-owned named native input if they need submission. Reset restores the
448
+ initial connected values silently. Existing input events and isolated component entry points are preserved.
449
+
450
+ `layout` is `vertical` (default), `horizontal`, or `inline`; `--hy-form-gap` and `--hy-form-label-width`
451
+ control spacing and horizontal labels. `values` and `formData` are fresh snapshots; repeated names become
452
+ arrays in `values`. `setValues(record)` updates supported native/value/checked fields silently.
453
+ Native and `hy-button` submit/reset actions work inside `hy-form`, as does Enter in single-line inputs.
454
+ `validate()` returns `Promise<boolean>`; `submit()` validates and emits the cancelable, composed
455
+ `form-submit` event with `{ values, formData }`. It resolves to the event's accepted status, and never
456
+ navigates or sends a network request. `form-invalid` carries `{ errors }`; `form-reset` signals reset.
457
+ Later edits, replacement submissions or disconnect prevent an old async validation from submitting.
458
+
459
+ Form Item owns one field. `name` supplies the field name when it has none; `label`, `required`, `help`,
460
+ and external `error` configure its presentation. Labels focus the field, and labels/error descriptions
461
+ are applied to the actual accessible control. `validateTrigger` (`validate-trigger`) is `blur` by default,
462
+ or `change`/`submit`. `rules` accepts `{ required, min, max, pattern, message, validator }`; min/max
463
+ measure string/array length or a numeric value. A validator receives `(value, signal)` and returns a
464
+ message or no message, synchronously or as a Promise. The signal cancels superseded validation.
465
+ `status` is read-only (`''`, `validating`, `success`, `error`); `clearValidation()` clears feedback.
466
+ `field-validate` emits `{ name, valid, error }`. Explicit native constraints remain in effect.
467
+
468
+ ```ts
469
+ item.rules = [{ min: 3, message: 'Use at least 3 characters' }, {
470
+ validator: async (value, signal) => {
471
+ const available = await checkName(value, { signal });
472
+ return available ? '' : 'Name already used';
473
+ },
474
+ }];
475
+ form.addEventListener('form-submit', event => {
476
+ event.preventDefault();
477
+ saveProject(event.detail.values);
478
+ });
479
+ ```
480
+
481
+ ## Upload
482
+
483
+ Import `defineUploadComponents` from `@haiyue/ui/upload`. File transport stays application-owned;
484
+ the component never chooses a server or sends a request by itself.
485
+
486
+ ```html
487
+ <hy-upload name="assets" drag multiple accept=".png,.jpg,.txt"
488
+ max-count="3" max-size="1048576" auto-upload="false">Drop files here</hy-upload>
489
+ ```
490
+
491
+ ```ts
492
+ upload.beforeUpload = async (file, files) => file.size <= 1024 * 1024;
493
+ upload.request = ({ file, signal, onProgress }) => uploadAsset(file, { signal, onProgress });
494
+ await upload.upload();
495
+ ```
496
+
497
+ `accept`, `multiple`, `disabled`, `drag`, `maxCount`, `maxSize` (bytes), `autoUpload`, and `showFileList`
498
+ configure selection; a zero limit means unlimited. The file input's type/size/count checks are applied
499
+ to both selection and drag/drop. `beforeUpload` can asynchronously veto a file; stale selection work is
500
+ discarded after disable, reset, replacement or disconnect. `autoUpload` defaults to true and only starts
501
+ work if an application `request` function exists. Input and drop content can be customized with `label`
502
+ and the default slot. `openFileDialog()` opens the picker; `focus()` targets its button.
503
+
504
+ `fileList` is a copied list of `{ uid, name, status, percent?, file?, size?, type?, response?, error? }`.
505
+ Statuses are `ready`, `uploading`, `done`, and `error`. `files` returns actual `File` instances.
506
+ `upload(uid?)` starts/retries files; `abort(uid?)` cancels and returns them to `ready`;
507
+ `removeFile(uid)` emits cancelable `file-remove` before removing and aborting a file.
508
+ `upload-change` carries `{ file, fileList, reason }`, including progress/success/error/abort, and
509
+ `file-reject` carries `{ file, reason, message }`. Request callbacks receive an AbortSignal and a
510
+ 0–100 progress callback; removed/replaced/disconnected requests cannot report stale success.
511
+ Native form submission includes actual File objects under `name`; metadata-only preloaded entries
512
+ are displayed but do not fabricate files. `required` checks whether the list is empty.
513
+ Style `dropzone`, `trigger`, `list`, `file`, `file-name`, `file-status`, `progress`, `remove`, `retry`,
514
+ and `message` parts through the existing semantic theme tokens.
515
+
516
+ ## AutoComplete
517
+
518
+ Import `defineAutoCompleteComponents` from `@haiyue/ui/auto-complete`.
519
+
520
+ ```html
521
+ <hy-auto-complete name="asset" aria-label="Asset search" allow-clear search-delay="150"></hy-auto-complete>
522
+ ```
523
+
524
+ ```ts
525
+ autoComplete.options = [
526
+ { value: 'ocean', label: 'Ocean scene' },
527
+ { value: 'archived', label: 'Archived scene', disabled: true },
528
+ ];
529
+ autoComplete.addEventListener('search', event => fetchSuggestions(event.detail.value));
530
+ autoComplete.addEventListener('option-select', event => console.log(event.detail.option));
531
+ ```
532
+
533
+ Free text remains valid without selecting an option. `value`, `options`, `open`, `disabled`, `readOnly`,
534
+ `loading`, `allowClear`, `placeholder`, and `searchDelay` are properties. Options can also be supplied
535
+ as JSON in `options`. Default matching searches label/value without case sensitivity; `filterOption`
536
+ accepts a function or `false` for application-filtered results. Set `loading` while fetching and use
537
+ `not-found-content` to customize empty feedback. `search` emits `{ value }` after the configured delay;
538
+ superseded timers and IME intermediate searches are canceled. The application owns request cancellation
539
+ and stale network-response handling. Arrow keys skip disabled options, Enter selects, and Escape/Tab
540
+ dismiss. Native editing and composition keys are preserved.
541
+
542
+ `value-change` emits `{ value }` for user edits/selections; `option-select` emits `{ value, option }`;
543
+ `clear` and `open-change` are also composed events. Programmatic value assignments are silent.
544
+ Selection and clear preserve native input notifications. `name`, `required`, `minlength`, `maxlength`
545
+ and `pattern` support native forms and constraints; reset and disabled fieldsets work. `focus()`/`blur()`
546
+ target the real input. Parts are `control`, `input`, `clear`, `panel`, `list`, `option`, and `status`.
547
+
548
+ ## Menu
549
+
550
+ The isolated `@haiyue/ui/menu` entry exposes `HYMenu` and `defineMenuComponents()`.
551
+
552
+ ```ts
553
+ menu.items = [
554
+ { key: 'home', label: 'Home', icon: '⌂' },
555
+ { key: 'assets', label: 'Assets', children: [{ key: 'scenes', label: 'Scenes' }] },
556
+ { key: 'divider', type: 'divider' },
557
+ { key: 'settings', label: 'Settings', href: '/settings' },
558
+ ];
559
+ menu.selectedKeys = ['home'];
560
+ ```
561
+
562
+ Items have unique string keys and optional labels, text icons, hrefs, disabled state, children and
563
+ `type: 'group' | 'divider'`. Disabled parents disable their descendants. Cycles, duplicate keys and
564
+ invalid input are discarded. Link navigation permits http/https/mailto/tel and ordinary relative URLs.
565
+ `mode` is `inline` (default), `vertical`, or `horizontal`; `collapsed` provides a compact icon rail.
566
+ Inline children expand in place, while vertical/horizontal submenus use top-layer popups. `multiple`,
567
+ `selectedKeys` and `openKeys` control selection/expansion (array attributes use JSON). Programmatic updates
568
+ are silent; cancelable `menu-select` emits `{ key, item, selectedKeys }` before selection/navigation,
569
+ and `open-change` emits `{ openKeys }` for user expansion. Cancel a selection to prevent navigation.
570
+ Menus provide roving tab focus, arrow/Home/End navigation, Escape return to parent, and text typeahead.
571
+ Outside clicks close floating submenus. Parts are `menu`, `item`, `submenu`; width tokens include
572
+ `--hy-menu-width`, `--hy-menu-collapsed-width`, and `--hy-menu-popup-width`.
573
+
574
+ ## Pagination
575
+
576
+ Import `definePaginationComponents` from `@haiyue/ui/pagination` for lists or server-side pages.
577
+
578
+ ```html
579
+ <hy-pagination total="153" page="1" page-size="10" show-size-changer show-quick-jumper></hy-pagination>
580
+ ```
581
+
582
+ `page`, `pageSize`, `total`, `pageSizeOptions`, `disabled`, `simple`, `showSizeChanger` and
583
+ `showQuickJumper` have properties and corresponding kebab-case attributes. `pageCount` is read-only;
584
+ empty data still uses page 1. Invalid pages/sizes normalize, and huge totals render a bounded page window.
585
+ `page-size-options` accepts comma-separated numbers or a JSON numeric array. `show-total="false"`
586
+ hides the range, `hide-on-single-page` hides unnecessary navigation, and `size="small"` makes it compact.
587
+ User actions emit composed `page-change` with `{ page, pageSize, total, source }`, where source is
588
+ `page`, `size`, or `jump`. Programmatic changes are silent. Page-size changes retain the first visible
589
+ record within the new page. Native buttons/selects and the Enter-committed jumper work with keyboard;
590
+ Left/Right follow writing direction and Home/End reach the boundaries. No data fetching is implicit.
591
+ Parts are `nav`, `pages`, `page`, `previous`, `next`, `total`, `page-size`, and `jumper`.
592
+
593
+ ## TreeSelect
594
+
595
+ Import `defineTreeSelectComponents` from `@haiyue/ui/tree-select`. Its entry does not import/register Tree.
596
+
597
+ ```ts
598
+ treeSelect.options = [{ value: 'assets', label: 'Assets', selectable: false, children: [
599
+ { value: 'ocean', label: 'Ocean scene' },
600
+ { value: 'locked', label: 'Archived', disabled: true },
601
+ ] }];
602
+ treeSelect.multiple = true;
603
+ treeSelect.values = ['ocean'];
604
+ ```
605
+
606
+ Options have unique `value`, `label`, optional `disabled`, `selectable`, `expanded`, and `children`.
607
+ `value` is a string in single mode and a string array in multiple mode; `values` always exposes an array.
608
+ The multiple `value` attribute uses JSON. Multiple selection is independent: selecting a parent does not
609
+ implicitly select its descendants. Selected values survive async option replacement; unknown labels
610
+ temporarily show their values. `expandedKeys` / `expanded-keys` controls expansion.
611
+ `searchable` and `clearable` default to true (use `="false"` to disable); `loading`, `disabled`,
612
+ `readOnly`, `open`, and `placeholder` control interaction. Search preserves matching ancestors and
613
+ temporarily expands paths; it does not change stored expansion. `search` emits `{ text }`; consumers
614
+ own async requests and option updates. `not-found-content` customizes empty feedback.
615
+
616
+ The input keeps focus while aria-activedescendant identifies the active tree item. Arrows expand,
617
+ collapse and navigate, Enter selects, and Escape/Tab close. IME confirmation does not select a node.
618
+ `value-change` carries `{ value, values, options }` and is followed by a composed `change` event;
619
+ `expand-change` carries `{ expandedKeys }`. Programmatic assignments are silent. Named values participate
620
+ in FormData (repeated names for multiple values), required/custom validation, reset and disabled fieldsets.
621
+ `HYForm.setValues()` accepts arrays for multiple TreeSelect and native multiple select fields.
622
+ Parts include `control`, `input`, `tags`, `tag`, `clear`, `panel`, `tree`, `option`, `toggle`, and `status`.
623
+ AutoComplete/TreeSelect inherit semantic theme tokens and `--hy-popup-max-height`/`--hy-popup-z-index`.
624
+
625
+ ## Image and Image Preview
626
+
627
+ Use the independent `@haiyue/ui/image` and `@haiyue/ui/image-preview` entries to register
628
+ `defineImageComponents()` and `defineImagePreviewComponents()` respectively.
629
+
630
+ ```html
631
+ <hy-image src="ocean.png" alt="Ocean scene" width="280" height="180"
632
+ fit="cover" loading="lazy" fallback="placeholder.png"></hy-image>
633
+ ```
634
+
635
+ Image supports native `srcset`/`sizes` attributes, `src`, `alt`, `width`, `height`, `fit`, `loading`,
636
+ `fallback`, `preview` (default true), and `previewSrc` (`preview-src`) for a higher-resolution source.
637
+ Width/height accept numbers or CSS lengths. `status` is read-only: `empty`, `loading`, `loaded`, or `error`.
638
+ The frame also follows CSS width/height set on the host. With both dimensions constrained, `fit` uses
639
+ native `object-fit` semantics: `contain` shows the complete image with letterboxing, `cover` crops to fill,
640
+ `fill` stretches, `none` keeps the original size, and `scale-down` never enlarges. For oversized images,
641
+ `scale-down` matches `contain`; for smaller images it matches `none`. Constraining only the width retains
642
+ the image's natural aspect ratio.
643
+ `placeholder` and `fallback` slots customize loading/error content; `fallback` URL is tried once after
644
+ the original fails. Source changes detach old listeners so stale resources cannot replace new state.
645
+ `image-load` carries `{ src, naturalWidth, naturalHeight }`, and `image-error` carries `{ src, fallback }`.
646
+ `showPreview()`/`hidePreview()` control the single-image viewer, with `preview-open-change` notifications.
647
+ Parts include `frame`, `image`, `placeholder`, `error`, and `preview-trigger`; the radius/background use
648
+ `--hy-image-radius`/`--hy-image-bg` and semantic tokens.
649
+
650
+ ```ts
651
+ preview.images = [
652
+ { src: 'ocean.png', alt: 'Ocean', caption: 'Ocean scene' },
653
+ { src: 'moon.png', alt: 'Moon' },
654
+ ];
655
+ preview.show(0);
656
+ ```
657
+
658
+ Standalone Image Preview takes `images` (objects or URL strings; JSON attribute supported), `current`
659
+ (zero-based), `open`, `show(index?)`, and `hide()`. It uses a native modal dialog with keyboard focus
660
+ containment, Escape/backdrop dismissal and return focus. Toolbar controls provide previous/next,
661
+ zoom, rotation and reset; Left/Right switch images, wheel zooms, and dragging pans a zoomed image.
662
+ Navigation resets transforms. Loading and failures have visible feedback; empty lists close the viewer.
663
+ `open-change` carries `{ open, index }`; `preview-change` carries `{ index, item }`. Disconnect releases
664
+ modality and image listeners. Common preview parts are `preview`, `toolbar`, `stage`, `preview-image`,
665
+ `preview-status`, `caption`, `counter`, `previous`, `next`, `in`, `out`, `left`, `right`, `reset`, and `close`.
666
+ `--hy-image-preview-bg`, `--hy-image-preview-text-color` and `--hy-image-preview-mask-color`
667
+ customize its surface, overlay text and backdrop.
668
+
669
+ ## Portable component semantics (M24 G03/G05)
120
670
 
121
671
  `@haiyue/ui/core` provides platform-independent component types, validation, selection/input/action
122
672
  controllers and the `PlatformView` lifetime contract. `@haiyue/ui/portable` provides `HYPage`, selector
@@ -150,7 +700,7 @@ elements. It introduces no runtime package dependencies or automatic registratio
150
700
  [Web adapter guide](docs/web-adapter.md) and [interactive example](examples/portable-ui/index.html).
151
701
  Run `npm run test:web-adapter` for Chromium/WebKit regression coverage.
152
702
 
153
- These APIs are under development and have not been published. Mobile mapping is G06, desktop mapping
703
+ These APIs are included in the package and remain under development. Mobile mapping is G06, desktop mapping
154
704
  G08, and ShaderLab shared-page migration G07. Existing Web component APIs below remain independent. See the
155
705
  [portable UI guide](docs/portable-ui.md) and [typed composition example](test/portable/fixtures/settings-page.ts).
156
706
  Run `npm run verify:portable` for semantics, no-DOM types, and an isolated offline tarball consumer.
@@ -297,6 +847,34 @@ semantic status. Numeric counts are capped by `overflowCount` (99 by default); u
297
847
  preferences. Structural styling hooks include `wrapper`, `badge`, `badge-content`, `status`, `status-dot`, and
298
848
  `status-text` shadow parts.
299
849
 
850
+ ## Ribbon
851
+
852
+ `@haiyue/ui/ribbon` exports `HYRibbon`, `HYRibbonPlacement` and `defineRibbonComponents()`.
853
+ Register it explicitly, or use the root `defineHaiyueUI()` registration.
854
+
855
+ ```html
856
+ <hy-ribbon text="Featured" placement="end">
857
+ <article>Your content</article>
858
+ </hy-ribbon>
859
+
860
+ <hy-ribbon placement="start" color="var(--hy-success-color)">
861
+ <strong slot="text">★ Recommended</strong>
862
+ <article>Your content</article>
863
+ </hy-ribbon>
864
+ ```
865
+
866
+ `text` supplies the label, and the named `text` slot takes precedence when provided. An empty label hides
867
+ the ribbon while retaining its content. `placement` defaults to `end` and accepts `start`, using the inherited
868
+ text direction. `color` accepts a CSS color, including custom-property references. Clearing it restores the
869
+ theme background. Content in the default slot retains its DOM, input state and keyboard interaction.
870
+
871
+ Style `::part(wrapper)`, `::part(content)`, `::part(ribbon)`, `::part(text)` and `::part(fold)`.
872
+ Inherited `--hy-ribbon-bg-color`, `--hy-ribbon-text-color`, `--hy-ribbon-font-size`, `--hy-ribbon-radius`,
873
+ `--hy-ribbon-height`, `--hy-ribbon-padding`, `--hy-ribbon-offset` and `--hy-ribbon-fold-size` override the
874
+ shared color, typography, spacing and sizing tokens. A valid `color` attribute takes precedence over
875
+ `--hy-ribbon-bg-color`. The fold darkens the ribbon color. Allow room for the label near the top of the content
876
+ and for the fold beyond its edge when composing surrounding layouts.
877
+
300
878
  ## Collapse
301
879
 
302
880
  Import `@haiyue/ui/collapse` and assign typed `items` containing `key`, `title`, optional `content`, `extra`,
@@ -306,6 +884,24 @@ group to one. Configure `iconPosition`, `collapsible`, `bordered`, `ghost`, and
306
884
  to a labelled region, and user changes emit the composed `collapse-change` event with the active keys and
307
885
  changed panel. The component exposes structural shadow parts from `collapse` and `panel` through `body`.
308
886
 
887
+ Enable `animated` / `animated = true` for smooth opening and closing. Animation is off by default;
888
+ initial rendering stays immediate. Set `animation-duration` / `animationDuration` in milliseconds
889
+ (default 200, range 0–10,000); zero disables animation. Without the attribute, the inherited
890
+ `--hy-collapse-animation-duration` token (for example `250ms`) supplies the duration.
891
+ `--hy-collapse-animation-easing` customizes the easing (default `ease`).
892
+
893
+ ```html
894
+ <hy-collapse animated animation-duration="250" destroy-on-hidden></hy-collapse>
895
+ ```
896
+
897
+ Rapid toggles reverse from the current height, and content resizing during expansion updates the target height.
898
+ Closed panels become inert and hidden from assistive technology immediately; focus returns to their header
899
+ when needed. With `destroyOnHidden`, content is removed after the closing animation finishes.
900
+ Disabling animation, setting duration to zero, or enabling reduced-motion preferences settles immediately.
901
+ Animations and content observers are released on disconnect. The existing `collapse-change` event still fires
902
+ when the expanded state changes, rather than waiting for animation completion. These options extend `HYCollapse`;
903
+ no new package exports or registration functions are required.
904
+
309
905
  ## Affix
310
906
 
311
907
  Import `@haiyue/ui/affix` to pin actions, navigation, or status content after it crosses a viewport threshold.
@@ -597,7 +1193,38 @@ Apply a theme to the document or to a component subtree. Tokens inherit through
597
1193
  - `light` / Haiyue Moonlight: moon white, pale ice blue, cyan and a soft violet highlight.
598
1194
  - `dark` / Haiyue Nightfall: deep navy, blue violet, cool white and a restrained gold highlight.
599
1195
 
600
- All theme tokens use the `--hy-` prefix and may be overridden by consuming products.
1196
+ The two skins share the same design scales. Define overrides on the element that carries `data-hy-theme`
1197
+ or on a descendant wrapper. For overrides on the same element, load product rules after the theme stylesheet
1198
+ and match the theme selector's specificity.
1199
+
1200
+ | Category | Shared tokens | Examples |
1201
+ | --- | --- | --- |
1202
+ | Semantic colors | Surface, text, border, accent, focus and status | `--hy-surface-color`, `--hy-text-color`, `--hy-accent-color`, `--hy-success-color` |
1203
+ | Spacing | `--hy-space-*` on a 2px scale | `--hy-space-2` = 4px, `--hy-space-4` = 8px, `--hy-space-8` = 16px |
1204
+ | Typography | Font families, `--hy-font-size-*`, `--hy-line-height-*`, `--hy-font-weight-*` | `--hy-font-size-sm` = 12px, `--hy-font-size-md` = 14px, `--hy-line-height-relaxed` = 1.5 |
1205
+ | Corner radius | `--hy-radius-xs` through `--hy-radius-xl` and `--hy-radius-full` | `--hy-radius-sm` = 4px, `--hy-radius-md` = 6px, `--hy-radius-lg` = 8px |
1206
+ | Control height | `--hy-control-height-xs`, `-sm`, `-md`, `-lg` | 24px, 28px, 34px, 44px |
1207
+
1208
+ ```html
1209
+ <section data-hy-theme="light" class="product-skin">
1210
+ <hy-input aria-label="Project name"></hy-input>
1211
+ <hy-button>Save</hy-button>
1212
+ </section>
1213
+ ```
1214
+
1215
+ ```css
1216
+ [data-hy-theme="light"].product-skin {
1217
+ --hy-accent-color: #a44932;
1218
+ --hy-space-4: 12px;
1219
+ --hy-space-5: 15px;
1220
+ --hy-font-size-sm: 15px;
1221
+ --hy-radius-sm: 10px;
1222
+ --hy-control-height-sm: 38px;
1223
+ }
1224
+ ```
1225
+
1226
+ Components resolve their specific tokens first where available. For example, `--hy-input-radius` overrides
1227
+ `--hy-radius-sm` for Input. Each component provides usable fallback values when no theme is applied.
601
1228
 
602
1229
  ## Component examples
603
1230
 
@@ -610,12 +1237,69 @@ npm run examples
610
1237
  ```
611
1238
 
612
1239
  Then open <http://localhost:4173/>. The gallery provides a left-side component index and live examples for
613
- every exported component, including editable parameters and event output. The gallery shell itself dogfoods
1240
+ every exported component, including editable parameters and event output. Open **设计规范** to compare
1241
+ Moonlight, Nightfall, and a custom skin on the same controls and inspect the CSS and current token values.
1242
+ The compact skin picker also offers **自定义**, starting from Terracotta. Its gear button opens a live
1243
+ preview panel for colors (including alpha values), fonts, spacing, radii, and control heights. Changes and
1244
+ the selected skin are saved locally; **恢复陶土** resets the custom values, and **应用皮肤** applies them to the
1245
+ gallery. The same picker remains available above the introduction on mobile screens.
1246
+ The gallery shell itself dogfoods
614
1247
  Haiyue UI: theme actions, component search, command results, status, and example action controls use the
615
1248
  published Web Components rather than parallel page-only widgets. The navigation/content shell and eligible
616
1249
  preview/control cards use `hy-split` for keyboard- and pointer-adjustable sizing. Usage blocks are rendered as
617
1250
  read-only CodeMirror editors with HTML, JavaScript, and CSS syntax highlighting.
618
1251
 
1252
+ ## Empty, Result, Avatar, Card and Descriptions
1253
+
1254
+ These five presentation components have focused, side-effect-free entries (`@haiyue/ui/empty`,
1255
+ `/result`, `/avatar`, `/card`, `/descriptions`) and are included in `defineHaiyueUI()`.
1256
+ Each entry exposes its `HY…` class and `define…Components()` registration function. Styling inherits
1257
+ the semantic color, font, spacing and radius tokens; no runtime dependency is added.
1258
+
1259
+ | Component | Properties / attributes | Content slots |
1260
+ | --- | --- | --- |
1261
+ | `HYEmpty` / `hy-empty` | `description` (default `No data`), `image` (`default`, `simple`, `none`), `size` (`small`, `default`) | `image`, `description`, default actions |
1262
+ | `HYResult` / `hy-result` | `status` (`success`, `info`, `warning`, `error`, `403`, `404`, `500`), `heading`, `description` | `icon`, `heading`, `description`, default details, `extra` actions |
1263
+ | `HYAvatar` / `hy-avatar` | `src`, native `srcset`/`sizes` attributes, `alt`, `text`, `size` (`small`, `default`, `large`, or 16–256 pixels), `shape` (`circle`, `square`), `fit` (`cover`, `contain`, `fill`), read-only `status` | default image fallback |
1264
+ | `HYCard` / `hy-card` | `heading`, `bordered` (default true; `bordered="false"` removes it), `hoverable`, `loading`, `size` (`small`, `default`) | `heading`, `extra`, `cover`, default body, `footer` |
1265
+ | `HYDescriptions` / `hy-descriptions` | `items`, `heading`, `column` (1–6, default 3), `layout` (`horizontal`, `vertical`), `bordered`, `size`, `responsive` (default true), `emptyText` (`empty-text`) | `heading`, `extra`, `label-{key}`, `value-{key}` |
1266
+
1267
+ ```js
1268
+ import { defineDescriptionsComponents } from '@haiyue/ui/descriptions';
1269
+ defineDescriptionsComponents();
1270
+ const details = document.querySelector('hy-descriptions');
1271
+ details.items = [
1272
+ { key: 'name', label: 'Project', value: 'Ocean' },
1273
+ { key: 'files', label: 'Files', value: 0 },
1274
+ { key: 'notes', label: 'Notes', value: 'More room for this value', span: 'filled' },
1275
+ ];
1276
+ ```
1277
+
1278
+ `HYDescriptionItem` uses optional unique string `key` (defaults to the item index), `label`, primitive
1279
+ `value` and optional `span` (1–6 or `filled` to consume the remaining row). Items are copied; duplicate
1280
+ keys reject a property update, while invalid JSON in the `items` attribute produces an empty list.
1281
+ Values render as text; use the named value/label slots for links, tags or inputs. `0` and `false` remain
1282
+ visible; null, missing and empty string values use `emptyText` (default `—`). Responsive layout follows
1283
+ the component's container: one column below 480px, up to two below 720px, otherwise `column`.
1284
+ Set `responsive="false"` to retain the configured columns. Resize observers disconnect on removal.
1285
+
1286
+ Avatar shows its default slot, `text`, or a person icon while loading and after failure. `status` is
1287
+ `empty`, `loading`, `loaded` or `error`. `avatar-load` carries `{ src, naturalWidth, naturalHeight }` and
1288
+ `avatar-error` carries `{ src }`; both bubble across shadow roots. Superseded requests and disconnected
1289
+ instances ignore stale image events. Supply `alt` or `aria-label` for the user name; explicit `alt=""`
1290
+ makes the avatar decorative. `--hy-avatar-size`, `--hy-avatar-font-size`, `--hy-avatar-radius`,
1291
+ `--hy-avatar-bg-color` and `--hy-avatar-text-color` provide local overrides.
1292
+
1293
+ Card loading hides and makes its body inert without destroying inputs, and hides the footer until
1294
+ loading ends. `hoverable` adds a visual hover treatment; use actual slotted links/buttons for actions.
1295
+ Empty and Result preserve slotted controls, and Result exposes a labelled region without unsolicited
1296
+ live announcements. All fallback strings render as text. Useful surface parts are `empty`, `image`,
1297
+ `description`, `actions`; `result`, `icon`, `heading`, `content`, `extra`; `avatar`, `image`, `fallback`,
1298
+ `text`; `card`, `header`, `heading`, `cover`, `body`, `loading`, `footer`; and `list`, `item`, `label`,
1299
+ `value` respectively. Component CSS hooks also include `--hy-empty-padding`, `--hy-empty-image-size`,
1300
+ `--hy-result-padding`, `--hy-result-icon-size`, `--hy-card-radius`, `--hy-card-bg-color`,
1301
+ `--hy-card-body-padding`, `--hy-descriptions-label-width`, `--hy-descriptions-cell-padding` and gap tokens.
1302
+
619
1303
  ## Expandable container
620
1304
 
621
1305
  Explicit export: `@haiyue/ui/expandable` → `HYExpandable`, `defineExpandableComponents`,
@@ -655,7 +1339,7 @@ npm run release:check
655
1339
  ```
656
1340
 
657
1341
  Candidates: `.artifacts/packages/`. Review API changes before `npm run api:update`.
658
- See [release review](review/release-0.1.2.md).
1342
+ See [release review](review/release-0.2.2.md).
659
1343
 
660
1344
  ### 共享组件目录(开发中)
661
1345
 
@@ -674,3 +1358,21 @@ See [release review](review/release-0.1.2.md).
674
1358
  Native 仓库的 `examples/ui-validation/mobile` 提供独立「Haiyue UI」组件实验室;折叠内容、步骤导航与按钮组是基础节点组合示例,不是新增协议节点。
675
1359
 
676
1360
  Web 的 `hy-badge` 新增可选 `literal` 属性(默认为 false):启用后 `count` 按原始文字显示,保留 0、前导零和大数字。普通计数的隐藏零值、截断,以及 status/text 模式保持原行为;共享 Badge 适配显式启用此模式。
1361
+
1362
+ The portable presentation contract adds optional semantic `Button.variant`
1363
+ (`primary`, `secondary`, `quiet`, `danger`), `size` and vector `icon` names;
1364
+ `Text.textStyle` (`title`, `body`, `caption`) and `tone`; `Tabs.variant`
1365
+ (`underline`, `segmented`); and native `Select.presentation`. Existing nodes stay
1366
+ valid. `HYTheme.typography` scales with fontScale, and optional selected, pressed,
1367
+ disabled, elevated and onAccent colors map to inherited `--hy-` properties.
1368
+ `HYIconName`, `HYButtonVariant`, `HYTextStyle` and `HYTypography` are explicitly
1369
+ exported from `@haiyue/ui/core`; `HY_ICONS` / `hyIconSvg` are explicitly exported
1370
+ from `@haiyue/ui/portable`, with no platform access or registration at import time.
1371
+
1372
+ Portable forms accept optional `FormGroup.description`, rendered as visible helper
1373
+ text and included in associated controls' accessible descriptions. Updating help
1374
+ or validation errors preserves the existing input, selection and composition.
1375
+ `@haiyue/ui/portable` explicitly exports `hyResponsiveGrid`,
1376
+ `hyResponsiveWorkspace`, `HYResponsiveGridOptions` and
1377
+ `HYResponsiveWorkspaceOptions`. These return logical-pixel layout data without
1378
+ reading window or platform globals, so hosts can use actual split-window sizes.