@haiyue/ui 0.2.2 → 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 (119) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +506 -2
  3. package/dist/adapters/web/renderer.js +1 -8
  4. package/dist/adapters/web/styles.d.ts +2 -3
  5. package/dist/adapters/web/styles.js +26 -23
  6. package/dist/alert.d.ts +39 -0
  7. package/dist/alert.js +144 -0
  8. package/dist/anchor.d.ts +60 -0
  9. package/dist/anchor.js +274 -0
  10. package/dist/auto-complete.d.ts +83 -0
  11. package/dist/auto-complete.js +267 -0
  12. package/dist/avatar.d.ts +45 -0
  13. package/dist/avatar.js +135 -0
  14. package/dist/badge.js +5 -5
  15. package/dist/border-beam.js +1 -1
  16. package/dist/breadcrumb.js +5 -5
  17. package/dist/button-group.js +8 -8
  18. package/dist/button.js +10 -10
  19. package/dist/card.d.ts +29 -0
  20. package/dist/card.js +101 -0
  21. package/dist/carousel.js +6 -6
  22. package/dist/cascader.js +12 -12
  23. package/dist/checkbox.d.ts +12 -0
  24. package/dist/checkbox.js +22 -6
  25. package/dist/collapse.js +6 -6
  26. package/dist/context-menu.js +3 -3
  27. package/dist/date-picker.js +13 -13
  28. package/dist/descriptions.d.ts +44 -0
  29. package/dist/descriptions.js +169 -0
  30. package/dist/dialog.js +11 -11
  31. package/dist/divider.js +2 -2
  32. package/dist/draggable.js +1 -1
  33. package/dist/drawer.js +12 -12
  34. package/dist/dropdown.js +3 -3
  35. package/dist/empty.d.ts +20 -0
  36. package/dist/empty.js +58 -0
  37. package/dist/expandable.js +4 -4
  38. package/dist/form-item.d.ts +60 -0
  39. package/dist/form-item.js +212 -0
  40. package/dist/form.d.ts +41 -0
  41. package/dist/form.js +154 -0
  42. package/dist/history-controls.js +5 -5
  43. package/dist/image-preview.d.ts +22 -0
  44. package/dist/image-preview.js +38 -0
  45. package/dist/image.d.ts +52 -0
  46. package/dist/image.js +152 -0
  47. package/dist/index.d.ts +48 -0
  48. package/dist/index.js +72 -0
  49. package/dist/input.d.ts +11 -0
  50. package/dist/input.js +29 -15
  51. package/dist/internal/anchored-popup.d.ts +19 -0
  52. package/dist/internal/anchored-popup.js +89 -0
  53. package/dist/internal/form-control.d.ts +22 -0
  54. package/dist/internal/form-control.js +52 -0
  55. package/dist/internal/image-viewer.d.ts +51 -0
  56. package/dist/internal/image-viewer.js +210 -0
  57. package/dist/internal/pagination.d.ts +35 -0
  58. package/dist/internal/pagination.js +169 -0
  59. package/dist/internal/popover-base.d.ts +87 -0
  60. package/dist/internal/popover-base.js +365 -0
  61. package/dist/internal/presentation.d.ts +2 -0
  62. package/dist/internal/presentation.js +28 -0
  63. package/dist/mentions.d.ts +115 -0
  64. package/dist/mentions.js +485 -0
  65. package/dist/menu-shared.d.ts +1 -1
  66. package/dist/menu-shared.js +3 -3
  67. package/dist/menu.d.ts +63 -0
  68. package/dist/menu.js +339 -0
  69. package/dist/modal.js +10 -10
  70. package/dist/notification.js +9 -9
  71. package/dist/pagination.d.ts +34 -0
  72. package/dist/pagination.js +73 -0
  73. package/dist/popconfirm.d.ts +6 -0
  74. package/dist/popconfirm.js +7 -0
  75. package/dist/popover.d.ts +6 -0
  76. package/dist/popover.js +7 -0
  77. package/dist/progress.d.ts +30 -0
  78. package/dist/progress.js +102 -0
  79. package/dist/qr-code.js +3 -3
  80. package/dist/radio.d.ts +10 -0
  81. package/dist/radio.js +18 -5
  82. package/dist/range.js +7 -7
  83. package/dist/rate.js +3 -3
  84. package/dist/resizable.js +4 -4
  85. package/dist/result.d.ts +22 -0
  86. package/dist/result.js +88 -0
  87. package/dist/ribbon.d.ts +19 -0
  88. package/dist/ribbon.js +106 -0
  89. package/dist/segmented.d.ts +39 -0
  90. package/dist/segmented.js +192 -0
  91. package/dist/select.d.ts +12 -0
  92. package/dist/select.js +31 -13
  93. package/dist/skeleton.js +10 -10
  94. package/dist/spin.d.ts +26 -0
  95. package/dist/spin.js +80 -0
  96. package/dist/steps.js +13 -13
  97. package/dist/switch.d.ts +44 -0
  98. package/dist/switch.js +104 -0
  99. package/dist/table.d.ts +0 -2
  100. package/dist/table.js +46 -87
  101. package/dist/tabs.js +7 -7
  102. package/dist/tag.js +8 -8
  103. package/dist/time-picker.js +10 -10
  104. package/dist/timeline.js +12 -12
  105. package/dist/toast.js +9 -9
  106. package/dist/tooltip.js +4 -4
  107. package/dist/tour.js +11 -11
  108. package/dist/tree-node.js +2 -2
  109. package/dist/tree-select.d.ts +94 -0
  110. package/dist/tree-select.js +398 -0
  111. package/dist/tree.js +6 -5
  112. package/dist/upload.d.ts +107 -0
  113. package/dist/upload.js +353 -0
  114. package/dist/virtual-keyboard.js +5 -5
  115. package/dist/virtual-list.js +4 -4
  116. package/dist/virtual-mouse.js +5 -5
  117. package/package.json +82 -1
  118. package/themes/haiyue-dark.css +51 -0
  119. package/themes/haiyue-light.css +51 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,36 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.3.0 - 2026-11-24
6
+
7
+ - 发布检查兼容 npm 11/12 的打包结果格式。
8
+
9
+ - 完善月白/夜阑皮肤的语义颜色、间距、字体、行高、圆角和控件尺寸 token,组件样式统一继承规范参数;新增设计规范示例和陶土皮肤。
10
+
11
+ - Table 与 Pagination 复用内部分页控件,统一页码渲染、条数选择、键盘/RTL 导航和基础样式;表格分页通过 `table-change` 输出筛选后的总数,切换每页条数时回到首页。
12
+
13
+ - 新增 `HYRibbon` / `<hy-ribbon>` 缎带组件,支持文字与富文本插槽、自定义配色、随 RTL 方向适配的起始侧/末尾侧位置和主题 token;提供独立入口、根注册及可调节的 Card 示例。
14
+
15
+ - 新增低优先级组件 `HYEmpty`、`HYResult`、`HYAvatar`、`HYCard` 和 `HYDescriptions`,支持空状态与结果展示、头像图片/文字回退、卡片插槽与保留正文的加载态、响应式属性详情与跨列;提供独立入口、显式注册、主题化交互示例及浏览器回归。
16
+
17
+ - 优化 example 页皮肤按钮的大小和居中对齐,增加以陶土为初始配置的自定义皮肤及独立设置入口;面板支持颜色、字体、间距、圆角、控件尺寸的实时预览、本地保存和恢复初始值,并适配移动端。
18
+
19
+ - 修复 Image 通过 CSS 指定组件尺寸时内部显示区域未跟随高度,导致 fit 效果不正确的问题;示例改用明显不同比例的原图和容器,补充五种 fit 模式说明及实际像素差异回归。
20
+
21
+ - 新增中优先级组件 `HYAutoComplete`、`HYMenu`、`HYPagination`、`HYTreeSelect`、`HYImage` 和 `HYImagePreview`,提供独立子路径、显式注册、主题化示例与浏览器契约测试;覆盖自由文本补全、层级导航、独立分页、树形单/多选、图片加载/回退及多图模态预览。
22
+ - AutoComplete/TreeSelect 支持原生表单提交、校验、禁用 fieldset 和重置;表单 `setValues()` 支持树选择与原生 select 的多值。共享内部浮层与图片预览实现,保持组件入口隔离和零运行时依赖。
23
+
24
+ - 新增独立入口及根注册的 `HYSwitch`、`HYProgress`、`HYSpin`、`HYPopover`、`HYPopconfirm`、`HYForm`、`HYFormItem` 和 `HYUpload`:覆盖设置开关、直线/圆环进度、延迟加载遮罩、可交互浮层与异步确认、表单与异步校验、文件选择/拖放/上传进度/重试/取消。
25
+ - Input、Select、Checkbox、Radio、Mentions 与新增 Switch、Upload 支持原生表单关联、FormData、禁用 fieldset 和重置;保留既有交互事件及按需导入边界。新增主题化参数示例、键盘/焦点/异步生命周期回归,并更新公开 API 和包体积基线。
26
+
27
+ - 新增 `HYMentions` / `<hy-mentions>` 及独立 `@haiyue/ui/mentions` 入口:支持多行提及输入、单个或多个触发前缀、候选过滤与禁用项、光标定位弹层、键盘选择、中文输入法、异步搜索与加载态;补齐主题变量、交互示例和浏览器回归。
28
+
29
+ ## 0.2.3 - 2026-10-27
30
+
31
+ - 新增可按需导入的 `HYAnchor` / `<hy-anchor>`、`HYAlert` / `<hy-alert>` 与 `HYSegmented` / `<hy-segmented>`:分别提供滚动锚点导航与当前项跟踪、四种语义反馈及可取消关闭、可访问的分段单选与禁用项键盘导航;Anchor 在点击触发的平滑滚动期间会锁定目标高亮,避免途经区块造成闪烁;同步加入根导出、独立子路径、主题化示例和浏览器回归。
32
+
33
+ - Windows 下 API 隔离门禁改用目录 junction,避免普通 symlink 权限导致的间歇性 `EPERM`,不影响发布包内容或组件运行时。
34
+
5
35
  ## 0.2.2 - 2026-10-23
6
36
 
7
37
  - 新增 `HYModal` / `<hy-modal>` 及独立 `@haiyue/ui/modal` 入口:支持原生模态层、标题/正文/页脚插槽、确认与取消按钮、可阻止的操作事件、异步确认加载态、独立遮罩/Esc/关闭按钮控制、受控状态、焦点恢复、滚动锁与隐藏内容卸载。
package/README.md CHANGED
@@ -48,6 +48,27 @@ 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
+
51
72
  ## Modal
52
73
 
53
74
  Import `defineModalComponents` from `@haiyue/ui/modal` and register once. `HYModal` is also exported by the root
@@ -278,6 +299,373 @@ button, or the application calls `search()`. Its detail contains `{ value, valid
278
299
  available. Style the `control`, `input`, `prefix`, `suffix`, and `search-button` parts or the
279
300
  `--hy-input-affix-*` and `--hy-input-search-*` tokens.
280
301
 
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
+
281
669
  ## Portable component semantics (M24 G03/G05)
282
670
 
283
671
  `@haiyue/ui/core` provides platform-independent component types, validation, selection/input/action
@@ -459,6 +847,34 @@ semantic status. Numeric counts are capped by `overflowCount` (99 by default); u
459
847
  preferences. Structural styling hooks include `wrapper`, `badge`, `badge-content`, `status`, `status-dot`, and
460
848
  `status-text` shadow parts.
461
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
+
462
878
  ## Collapse
463
879
 
464
880
  Import `@haiyue/ui/collapse` and assign typed `items` containing `key`, `title`, optional `content`, `extra`,
@@ -777,7 +1193,38 @@ Apply a theme to the document or to a component subtree. Tokens inherit through
777
1193
  - `light` / Haiyue Moonlight: moon white, pale ice blue, cyan and a soft violet highlight.
778
1194
  - `dark` / Haiyue Nightfall: deep navy, blue violet, cool white and a restrained gold highlight.
779
1195
 
780
- 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.
781
1228
 
782
1229
  ## Component examples
783
1230
 
@@ -790,12 +1237,69 @@ npm run examples
790
1237
  ```
791
1238
 
792
1239
  Then open <http://localhost:4173/>. The gallery provides a left-side component index and live examples for
793
- 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
794
1247
  Haiyue UI: theme actions, component search, command results, status, and example action controls use the
795
1248
  published Web Components rather than parallel page-only widgets. The navigation/content shell and eligible
796
1249
  preview/control cards use `hy-split` for keyboard- and pointer-adjustable sizing. Usage blocks are rendered as
797
1250
  read-only CodeMirror editors with HTML, JavaScript, and CSS syntax highlighting.
798
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
+
799
1303
  ## Expandable container
800
1304
 
801
1305
  Explicit export: `@haiyue/ui/expandable` → `HYExpandable`, `defineExpandableComponents`,
@@ -463,14 +463,7 @@ export class HYWebRenderer {
463
463
  this.#themeKeys.push(key);
464
464
  }
465
465
  }
466
- else if (environment.fontScale !== undefined) {
467
- const inherited = getComputedStyle(this.host);
468
- for (const [key, fallback] of [['--hy-font-size', 14], ['--hy-line-height', 22]]) {
469
- const base = parseFloat(inherited.getPropertyValue(key)) || fallback;
470
- this.#root.style.setProperty(key, `${base * fontScale}px`);
471
- this.#themeKeys.push(key);
472
- }
473
- }
466
+ this.#root.style.setProperty('--_hy-web-font-scale', String(theme ? 1 : fontScale));
474
467
  this.#root.dir = direction;
475
468
  flag(this.#root, 'data-hy-reduced-motion', !!environment.reducedMotion);
476
469
  this.#root.style.padding = safeArea === 'environment' ? ['top', 'right', 'bottom', 'left'].map(side => `env(safe-area-inset-${side}, 0px)`).join(' ') : safeArea.map(value => `${value}px`).join(' ');