@haiyue/ui 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +17 -2
- package/dist/adapters/web/controls.js +48 -8
- package/dist/adapters/web/renderer.js +8 -3
- package/dist/anchor.d.ts +2 -0
- package/dist/anchor.js +23 -4
- package/dist/border-beam.js +2 -1
- package/dist/cascader.js +7 -1
- package/dist/context-menu.js +0 -1
- package/dist/core/actions.js +7 -8
- package/dist/core/data.d.ts +1 -1
- package/dist/core/data.js +44 -10
- package/dist/core/platform-view.js +8 -2
- package/dist/core/selection.js +4 -4
- package/dist/core/semantics.d.ts +26 -0
- package/dist/core/semantics.js +8 -0
- package/dist/core/text.js +3 -3
- package/dist/core/validation.d.ts +3 -1
- package/dist/core/validation.js +23 -5
- package/dist/date-picker.js +6 -0
- package/dist/dialog.d.ts +4 -0
- package/dist/dialog.js +37 -16
- package/dist/draggable.js +4 -2
- package/dist/drawer.js +4 -12
- package/dist/dropdown.js +0 -1
- package/dist/input.js +3 -3
- package/dist/internal/focus.d.ts +2 -0
- package/dist/internal/focus.js +31 -0
- package/dist/internal/keyboard.d.ts +2 -0
- package/dist/internal/keyboard.js +12 -0
- package/dist/internal/numbers.d.ts +2 -0
- package/dist/internal/numbers.js +8 -0
- package/dist/modal.js +1 -30
- package/dist/notification.js +2 -1
- package/dist/portable/page.js +25 -14
- package/dist/radio.js +1 -1
- package/dist/resizable.js +4 -1
- package/dist/table.d.ts +3 -1
- package/dist/table.js +65 -42
- package/dist/time-picker.js +6 -0
- package/dist/toast.js +3 -2
- package/dist/tooltip.d.ts +6 -0
- package/dist/tooltip.js +103 -2
- package/dist/tour.js +15 -6
- package/dist/tree-model.d.ts +2 -0
- package/dist/tree-model.js +32 -11
- package/dist/tree.d.ts +0 -2
- package/dist/tree.js +8 -24
- package/dist/upload.d.ts +1 -0
- package/dist/upload.js +6 -1
- package/dist/virtual-keyboard.d.ts +1 -0
- package/dist/virtual-keyboard.js +67 -36
- package/dist/virtual-list.d.ts +1 -0
- package/dist/virtual-list.js +21 -4
- package/dist/virtual-mouse.js +2 -1
- package/dist/watermark.js +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.3.1 - 2026-11-24
|
|
6
|
+
|
|
7
|
+
- 完成剩余审查项:统一缺省数值属性,修复 Drawer/Dialog/Tour/Tooltip 的焦点、无障碍与生命周期,以及选择器禁用和 Radio 组互斥行为。
|
|
8
|
+
- Table 每次操作仅筛选/排序一次;表头、Anchor 与 VirtualList 保留可复用节点,Tree 批量删除只重建一次索引并支持超宽分支移动。
|
|
9
|
+
- VirtualKeyboard 按字素移动和删除,安全处理不支持选区 API 的输入类型,并统一禁用/只读检查。
|
|
10
|
+
- 完善 portable RadioGroup 的键盘/RTL 导航、Checkbox/RadioGroup/Rate 的模态初始焦点及 Rate 错误描述;修复订阅自定义比较器、不可变协议快照、事务复制开销与 PlatformView 双重失败诊断。
|
|
11
|
+
- 行为说明:Dialog 每次有效关闭同步发送一次 `dialog-close`;Tour 保留高亮目标交互,明确为非模态引导;core/portable 在不可变快照上校验并拒绝访问器、不可枚举字段及稀疏/扩展数组。
|
|
12
|
+
- API 门禁增加可达声明签名比较,覆盖接口、参数、联合类型与事件 detail;更新当前 23 种语义和 11 类 Web 复用组件的文档与回归。
|
|
13
|
+
- 修复 Tree 自定义渲染器与 Draggable/Resizable 子控件的键盘事件被容器快捷键截获;Resizable 的键盘移动遵守 `movable=false`。
|
|
14
|
+
- 保留 Tree、Dropdown 和 ContextMenu 在挂载前的程序赋值,以及断开重连后的当前数据;声明式属性初始化和后续属性更新继续生效。
|
|
15
|
+
- Upload 在接受文件选择/拖放或移除后发送一次 composed `change`,使 FormItem 校验和 Form 的异步提交使用已提交的文件列表;上传进度不使字段校验失效。
|
|
16
|
+
|
|
5
17
|
## 0.3.0 - 2026-11-24
|
|
6
18
|
|
|
7
19
|
- 发布检查兼容 npm 11/12 的打包结果格式。
|
package/README.md
CHANGED
|
@@ -508,6 +508,11 @@ Statuses are `ready`, `uploading`, `done`, and `error`. `files` returns actual `
|
|
|
508
508
|
`upload-change` carries `{ file, fileList, reason }`, including progress/success/error/abort, and
|
|
509
509
|
`file-reject` carries `{ file, reason, message }`. Request callbacks receive an AbortSignal and a
|
|
510
510
|
0–100 progress callback; removed/replaced/disconnected requests cannot report stale success.
|
|
511
|
+
After accepting a selection/drop batch or completing an uncanceled removal, the host emits one
|
|
512
|
+
bubbling, composed `change` event after synchronizing its file list and native form value. Form Item
|
|
513
|
+
change validation and pending Form submissions therefore observe the accepted list. Native picker
|
|
514
|
+
input does not bubble to field listeners before acceptance; rejected selections, vetoed removals, request
|
|
515
|
+
progress/status updates, and programmatic `fileList` assignment do not emit this field-edit event.
|
|
511
516
|
Native form submission includes actual File objects under `name`; metadata-only preloaded entries
|
|
512
517
|
are displayed but do not fabricate files. `required` checks whether the list is empty.
|
|
513
518
|
Style `dropzone`, `trigger`, `list`, `file`, `file-name`, `file-status`, `progress`, `remove`, `retry`,
|
|
@@ -695,7 +700,7 @@ no writes; reordering preserves instances. Applications persist values on `commi
|
|
|
695
700
|
|
|
696
701
|
The Web backend is available from `@haiyue/ui/adapters/web`: explicitly call
|
|
697
702
|
`definePortableWebComponents()`, construct `new HYWebRenderer(connectedElement, options)`, then pass it
|
|
698
|
-
to `HYPage`. It reuses
|
|
703
|
+
to `HYPage`. It reuses eleven existing Web Components and maps the other semantic kinds to browser
|
|
699
704
|
elements. It introduces no runtime package dependencies or automatic registration. See the
|
|
700
705
|
[Web adapter guide](docs/web-adapter.md) and [interactive example](examples/portable-ui/index.html).
|
|
701
706
|
Run `npm run test:web-adapter` for Chromium/WebKit regression coverage.
|
|
@@ -1339,7 +1344,7 @@ npm run release:check
|
|
|
1339
1344
|
```
|
|
1340
1345
|
|
|
1341
1346
|
Candidates: `.artifacts/packages/`. Review API changes before `npm run api:update`.
|
|
1342
|
-
See [release review](review/release-0.
|
|
1347
|
+
See [release review](review/release-0.3.1.md).
|
|
1343
1348
|
|
|
1344
1349
|
### 共享组件目录(开发中)
|
|
1345
1350
|
|
|
@@ -1376,3 +1381,13 @@ or validation errors preserves the existing input, selection and composition.
|
|
|
1376
1381
|
`hyResponsiveWorkspace`, `HYResponsiveGridOptions` and
|
|
1377
1382
|
`HYResponsiveWorkspaceOptions`. These return logical-pixel layout data without
|
|
1378
1383
|
reading window or platform globals, so hosts can use actual split-window sizes.
|
|
1384
|
+
|
|
1385
|
+
### 审查后的交互契约
|
|
1386
|
+
|
|
1387
|
+
数值属性缺省或为空时使用文档默认值;显式 `0` 继续按各控件范围处理。Table 每次同步操作共享一次筛选/排序结果,公开数据 getter 仍读取最新记录和筛选闭包;更新列结构会重建表头,排序/筛选保留表头控件。VirtualList 滚动复用重叠行,`refresh()` 或替换数据/渲染器会重建内容;焦点行移出窗口时焦点回到列表视口。
|
|
1388
|
+
|
|
1389
|
+
Drawer 的模态 Tab 环绕包含插槽中的 Shadow DOM 控件。Dialog 断开时释放原生 modal 状态,重新连接后按 `open` 恢复;每次有效关闭同步发送一次 `dialog-close`,重新打开不会被旧原生 close 事件撤销。Tour 是允许高亮目标交互的非模态引导,不声明 `aria-modal`;打开时清空步骤会以 `programmatic` 关闭并清理监听。Tooltip 在真实触发目标所在树中提供可访问描述,保留应用自己的 `aria-describedby`,禁用或移除时清理关系。
|
|
1390
|
+
|
|
1391
|
+
VirtualKeyboard 对 textarea 及支持选区 API 的 text/search/url/tel/password input 编辑;其他 input 类型安全忽略编辑。移动和删除按完整字素处理,包括 emoji、组合字符与 ZWJ 序列;禁用或只读目标不会被修改。portable RadioGroup 仅保留一个 Tab 停靠点,方向键跳过禁用项并按 RTL 导航;所有选择仍经过受控状态回填。
|
|
1392
|
+
|
|
1393
|
+
core/portable 仅接受普通数据对象与无空洞数组;拒绝访问器、不可枚举属性、符号键和额外数组属性,在不可变快照上验证,调用方后续修改不影响已接受的数据。新增辅助模块保持私有,不新增公开入口;API 基线现同时记录导出名与可达声明签名。
|
|
@@ -14,7 +14,7 @@ import { defineRadioComponents } from '../../radio.js';
|
|
|
14
14
|
import { defineRateComponents } from '../../rate.js';
|
|
15
15
|
import { defineBadgeComponents } from '../../badge.js';
|
|
16
16
|
import { defineDividerComponents } from '../../divider.js';
|
|
17
|
-
import { attribute, flag, focusable } from './dom.js';
|
|
17
|
+
import { attribute, flag, focusable, captureFocus } from './dom.js';
|
|
18
18
|
/** Registration is explicit and limited to the reused components. */
|
|
19
19
|
export function definePortableWebComponents() {
|
|
20
20
|
defineButtonComponents();
|
|
@@ -49,12 +49,47 @@ export function createControl(node, context, revision) {
|
|
|
49
49
|
let props = node.props;
|
|
50
50
|
const buttons = new Map(), groupName = `hy-portable-radio-${++radioGroupSequence}`;
|
|
51
51
|
host.setAttribute('role', 'radiogroup');
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
const enabled = () => props.disabled ? [] : props.options.filter(option => !option.disabled);
|
|
53
|
+
const focusValue = () => enabled().find(option => option.value === props.value)?.value ?? enabled()[0]?.value;
|
|
54
|
+
const focus = () => buttons.get(focusValue() ?? '')?.shadowRoot?.querySelector('input')?.focus();
|
|
55
|
+
const render = () => {
|
|
56
|
+
const tabValue = focusValue();
|
|
57
|
+
for (const [value, button] of buttons) {
|
|
58
|
+
flag(button, 'checked', props.value === value);
|
|
59
|
+
flag(button, 'disabled', !!props.disabled || !!props.options.find(o => o.value === value)?.disabled);
|
|
60
|
+
const input = button.shadowRoot?.querySelector('input');
|
|
61
|
+
if (input)
|
|
62
|
+
input.tabIndex = value === tabValue ? 0 : -1;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
56
65
|
listen(host, 'checked-change', event => { const detail = event.detail; if (detail.checked)
|
|
57
66
|
controller.choose(detail.value, reason); render(); });
|
|
67
|
+
listen(host, 'keydown', event => {
|
|
68
|
+
const key = event;
|
|
69
|
+
if (key.defaultPrevented || key.altKey || key.ctrlKey || key.metaKey)
|
|
70
|
+
return;
|
|
71
|
+
const options = enabled();
|
|
72
|
+
if (!options.length)
|
|
73
|
+
return;
|
|
74
|
+
const target = key.composedPath().find((node) => node instanceof HTMLElement && [...buttons.values()].includes(node));
|
|
75
|
+
const current = options.findIndex(option => buttons.get(option.value) === target);
|
|
76
|
+
const rtl = getComputedStyle(host).direction === 'rtl';
|
|
77
|
+
let next;
|
|
78
|
+
if (key.key === 'Home')
|
|
79
|
+
next = 0;
|
|
80
|
+
else if (key.key === 'End')
|
|
81
|
+
next = options.length - 1;
|
|
82
|
+
else if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(key.key)) {
|
|
83
|
+
const forward = key.key === 'ArrowDown' || key.key === (rtl ? 'ArrowLeft' : 'ArrowRight');
|
|
84
|
+
next = current < 0 ? 0 : (current + (forward ? 1 : -1) + options.length) % options.length;
|
|
85
|
+
}
|
|
86
|
+
else
|
|
87
|
+
return;
|
|
88
|
+
key.preventDefault();
|
|
89
|
+
controller.choose(options[next].value, 'keyboard');
|
|
90
|
+
render();
|
|
91
|
+
focus();
|
|
92
|
+
});
|
|
58
93
|
return { update(next) {
|
|
59
94
|
if (next.kind !== 'RadioGroup')
|
|
60
95
|
return;
|
|
@@ -65,6 +100,8 @@ export function createControl(node, context, revision) {
|
|
|
65
100
|
button.remove();
|
|
66
101
|
buttons.delete(value);
|
|
67
102
|
}
|
|
103
|
+
const restoreFocus = captureFocus(host.ownerDocument);
|
|
104
|
+
let cursor = host.firstElementChild;
|
|
68
105
|
for (const option of props.options) {
|
|
69
106
|
let button = buttons.get(option.value);
|
|
70
107
|
if (!button) {
|
|
@@ -74,11 +111,14 @@ export function createControl(node, context, revision) {
|
|
|
74
111
|
attribute(button, 'value', option.value);
|
|
75
112
|
attribute(button, 'label', option.label);
|
|
76
113
|
attribute(button, 'name', groupName);
|
|
77
|
-
|
|
114
|
+
if (button !== cursor)
|
|
115
|
+
host.insertBefore(button, cursor);
|
|
116
|
+
cursor = button.nextElementSibling;
|
|
78
117
|
}
|
|
79
118
|
render();
|
|
119
|
+
restoreFocus();
|
|
80
120
|
},
|
|
81
|
-
focus
|
|
121
|
+
focus, dispose() { controller.dispose(); buttons.clear(); } };
|
|
82
122
|
}
|
|
83
123
|
if (node.kind === 'Rate') {
|
|
84
124
|
let props = node.props, disposed = false, choosing = false;
|
|
@@ -101,7 +141,7 @@ export function createControl(node, context, revision) {
|
|
|
101
141
|
}
|
|
102
142
|
});
|
|
103
143
|
return { update(next) { if (next.kind !== 'Rate')
|
|
104
|
-
return; props = next.props; attribute(host, 'count', String(props.count)); flag(host, 'disabled', !!props.disabled); flag(host, 'readonly', !!props.readOnly); restore(); }, focus() {
|
|
144
|
+
return; props = next.props; attribute(host, 'count', String(props.count)); flag(host, 'disabled', !!props.disabled); flag(host, 'readonly', !!props.readOnly); restore(); }, focus() { host.shadowRoot?.querySelector('[role="slider"]')?.focus(); }, dispose() { disposed = true; } };
|
|
105
145
|
}
|
|
106
146
|
if (node.kind === 'Button') {
|
|
107
147
|
const button = host;
|
|
@@ -8,6 +8,10 @@ import { componentTags, createControl } from './controls.js';
|
|
|
8
8
|
import { applyAccessibility, applyLayout, attribute, captureFocus, deepActive, flag, focusable } from './dom.js';
|
|
9
9
|
import { componentCSS, rootCSS } from './styles.js';
|
|
10
10
|
const tags = { Row: 'div', Column: 'div', Grid: 'div', Overlay: 'div', Scroll: 'div', Text: 'span', Image: 'img', Icon: 'img', TextArea: 'textarea', FormGroup: 'fieldset', PlatformView: 'div', ...componentTags };
|
|
11
|
+
const a11ySelectors = {
|
|
12
|
+
Row: null, Column: null, Grid: null, Overlay: null, Scroll: null, Text: null, Image: null, Icon: null, TextArea: null, FormGroup: null, PlatformView: null, Badge: null, Divider: null,
|
|
13
|
+
Button: 'button', Checkbox: 'input', Toggle: 'input', RadioGroup: 'input', Rate: '[role="slider"]', Select: 'select', Tabs: '[role="tablist"],button', TextInput: 'input', Slider: 'button.upper', Dialog: 'dialog',
|
|
14
|
+
};
|
|
11
15
|
let rendererSequence = 0;
|
|
12
16
|
/** Browser-only adapter. Explicit registration and an attached, same-realm mount point are required. */
|
|
13
17
|
export class HYWebRenderer {
|
|
@@ -334,11 +338,12 @@ export class HYWebRenderer {
|
|
|
334
338
|
const description = [node.props.a11y?.description, groupProps?.description, node.props.a11y?.error ?? groupProps?.error].filter(Boolean).join('. ');
|
|
335
339
|
const a11y = label === undefined ? undefined : { ...node.props.a11y, label, ...(groupProps?.error && !node.props.a11y?.error ? { error: groupProps.error } : {}) };
|
|
336
340
|
applyAccessibility(element, a11y);
|
|
337
|
-
const
|
|
338
|
-
|
|
341
|
+
const selector = a11ySelectors[node.kind];
|
|
342
|
+
const targets = node.kind === 'RadioGroup' ? [...element.querySelectorAll('hy-radio')].flatMap(radio => [...radio.shadowRoot.querySelectorAll('input')])
|
|
343
|
+
: selector && element.shadowRoot ? [...element.shadowRoot.querySelectorAll(selector)] : [element];
|
|
339
344
|
for (const target of targets) {
|
|
340
345
|
// Tabs label belongs to the tablist; each tab keeps its option name.
|
|
341
|
-
if (!(element instanceof HYTabs) || target.getAttribute('role') === 'tablist')
|
|
346
|
+
if (node.kind !== 'RadioGroup' && (!(element instanceof HYTabs) || target.getAttribute('role') === 'tablist'))
|
|
342
347
|
applyAccessibility(target, a11y);
|
|
343
348
|
attribute(target, 'aria-description', description || undefined);
|
|
344
349
|
attribute(target, 'aria-invalid', (node.props.a11y?.error ?? groupProps?.error) ? 'true' : undefined);
|
package/dist/anchor.d.ts
CHANGED
package/dist/anchor.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { finiteNumber as readFiniteNumber } from './internal/numbers.js';
|
|
1
2
|
function finiteNumber(value, fallback, min, max) {
|
|
2
|
-
const number =
|
|
3
|
+
const number = readFiniteNumber(value, fallback);
|
|
3
4
|
return Number.isFinite(number) ? Math.min(max, Math.max(min, number)) : fallback;
|
|
4
5
|
}
|
|
5
6
|
/** Hash-link navigation that tracks targets inside the viewport or an owned scroll container. */
|
|
@@ -54,9 +55,14 @@ export class HYAnchor extends HTMLElement {
|
|
|
54
55
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
55
56
|
if (oldValue === newValue)
|
|
56
57
|
return;
|
|
57
|
-
if (name === 'items')
|
|
58
|
+
if (name === 'items') {
|
|
58
59
|
this._readItemsAttribute();
|
|
59
|
-
|
|
60
|
+
this._render();
|
|
61
|
+
}
|
|
62
|
+
else if (name === 'active-href')
|
|
63
|
+
this._syncActive();
|
|
64
|
+
else if (name === 'aria-label')
|
|
65
|
+
this._syncLabel();
|
|
60
66
|
if (this.isConnected && ['offset-top', 'bounds'].includes(name))
|
|
61
67
|
this.refresh();
|
|
62
68
|
}
|
|
@@ -143,7 +149,7 @@ export class HYAnchor extends HTMLElement {
|
|
|
143
149
|
_render() {
|
|
144
150
|
if (!this._list)
|
|
145
151
|
return;
|
|
146
|
-
this.
|
|
152
|
+
this._syncLabel();
|
|
147
153
|
this._list.replaceChildren();
|
|
148
154
|
const append = (items, depth) => {
|
|
149
155
|
for (const item of items) {
|
|
@@ -172,6 +178,19 @@ export class HYAnchor extends HTMLElement {
|
|
|
172
178
|
};
|
|
173
179
|
append(this._items, 0);
|
|
174
180
|
}
|
|
181
|
+
_syncLabel() {
|
|
182
|
+
this._nav.setAttribute('aria-label', this.getAttribute('aria-label') ?? 'On this page');
|
|
183
|
+
}
|
|
184
|
+
_syncActive() {
|
|
185
|
+
for (const link of this._list.querySelectorAll('a[data-href]')) {
|
|
186
|
+
const active = link.dataset.href === this.activeHref;
|
|
187
|
+
link.classList.toggle('active', active);
|
|
188
|
+
if (active)
|
|
189
|
+
link.setAttribute('aria-current', 'location');
|
|
190
|
+
else
|
|
191
|
+
link.removeAttribute('aria-current');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
175
194
|
_onClick(event, item) {
|
|
176
195
|
if (item.disabled) {
|
|
177
196
|
event.preventDefault();
|
package/dist/border-beam.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { finiteNumber as readFiniteNumber } from './internal/numbers.js';
|
|
1
2
|
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
2
3
|
const DEFAULT_THICKNESS = 2;
|
|
3
4
|
const DEFAULT_SPEED = 1;
|
|
4
5
|
const DEFAULT_COUNT = 1;
|
|
5
6
|
const BASE_DURATION_SECONDS = 6;
|
|
6
7
|
function finiteNumber(value, fallback) {
|
|
7
|
-
const number =
|
|
8
|
+
const number = readFiniteNumber(value, fallback);
|
|
8
9
|
return Number.isFinite(number) ? number : fallback;
|
|
9
10
|
}
|
|
10
11
|
/** Decorative animated border that follows the host's live rounded rectangle. */
|
package/dist/cascader.js
CHANGED
|
@@ -314,6 +314,10 @@ export class HYCascader extends HTMLElement {
|
|
|
314
314
|
return resolved;
|
|
315
315
|
}
|
|
316
316
|
_render() {
|
|
317
|
+
if (this.disabled && this.open) {
|
|
318
|
+
this.open = false;
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
317
321
|
const selected = this._resolveOptions(this._value);
|
|
318
322
|
const text = selected.map(option => option.label).join(this.displaySeparator);
|
|
319
323
|
this._label.textContent = text || this.placeholder;
|
|
@@ -392,7 +396,7 @@ export class HYCascader extends HTMLElement {
|
|
|
392
396
|
return row;
|
|
393
397
|
}
|
|
394
398
|
_activateOption(option, depth, focusNext = false) {
|
|
395
|
-
if (option.disabled)
|
|
399
|
+
if (this.disabled || option.disabled)
|
|
396
400
|
return;
|
|
397
401
|
const next = [...this._activePath.slice(0, depth), option.value];
|
|
398
402
|
this._activePath = next;
|
|
@@ -408,6 +412,8 @@ export class HYCascader extends HTMLElement {
|
|
|
408
412
|
this._commit(next, true);
|
|
409
413
|
}
|
|
410
414
|
_commit(value, close) {
|
|
415
|
+
if (this.disabled)
|
|
416
|
+
return;
|
|
411
417
|
this._value = this._normalizePath(value);
|
|
412
418
|
this._activePath = [...this._value];
|
|
413
419
|
this._reflectValue();
|
package/dist/context-menu.js
CHANGED
package/dist/core/actions.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { hyKey, hyValidateProps } from './validation.js';
|
|
1
|
+
import { hyKey, snapshotValidatedProps } from './validation.js';
|
|
3
2
|
export class HYButtonController {
|
|
4
3
|
key;
|
|
5
4
|
emit;
|
|
@@ -17,8 +16,8 @@ export class HYButtonController {
|
|
|
17
16
|
update(props) {
|
|
18
17
|
if (this.#disposed)
|
|
19
18
|
return;
|
|
20
|
-
|
|
21
|
-
this.#props =
|
|
19
|
+
props = snapshotValidatedProps('Button', props, { key: this.key });
|
|
20
|
+
this.#props = props;
|
|
22
21
|
}
|
|
23
22
|
/** Adapters pass the same gesture id for overlapping tap/click/accessibility callbacks. */
|
|
24
23
|
activate(reason = 'pointer', gesture) {
|
|
@@ -58,8 +57,8 @@ export class HYToggleController {
|
|
|
58
57
|
update(props) {
|
|
59
58
|
if (this.#disposed)
|
|
60
59
|
return;
|
|
61
|
-
|
|
62
|
-
this.#props =
|
|
60
|
+
props = snapshotValidatedProps('Toggle', props, { key: this.key });
|
|
61
|
+
this.#props = props;
|
|
63
62
|
}
|
|
64
63
|
choose(checked, reason = 'pointer') {
|
|
65
64
|
if (typeof checked !== 'boolean' || this.#disposed || this.#emitting || this.#props.disabled || this.#props.visible === false || checked === this.#props.checked)
|
|
@@ -97,12 +96,12 @@ export class HYSliderController {
|
|
|
97
96
|
update(props) {
|
|
98
97
|
if (this.#disposed)
|
|
99
98
|
return;
|
|
100
|
-
|
|
99
|
+
props = snapshotValidatedProps('Slider', props, { key: this.key });
|
|
101
100
|
if (!this.#props || props.value !== this.#props.value || props.min !== this.#props.min || props.max !== this.#props.max || props.step !== this.#props.step || props.disabled || props.visible === false) {
|
|
102
101
|
this.#draft = props.value;
|
|
103
102
|
this.#active = 0;
|
|
104
103
|
}
|
|
105
|
-
this.#props =
|
|
104
|
+
this.#props = props;
|
|
106
105
|
}
|
|
107
106
|
change(value, reason = 'pointer') {
|
|
108
107
|
if (this.#disposed || this.#props.disabled || this.#props.visible === false || !Number.isFinite(value))
|
package/dist/core/data.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** Internal structural comparison for immutable protocol data; never serializes props. */
|
|
2
2
|
export declare function equalData(a: unknown, b: unknown): boolean;
|
|
3
3
|
export declare function isSnapshot(value: object): boolean;
|
|
4
|
-
export declare function snapshot<T>(value: T): T;
|
|
4
|
+
export declare function snapshot<T>(value: T, reject?: (message: string, property: string) => never): T;
|
package/dist/core/data.js
CHANGED
|
@@ -11,17 +11,51 @@ export function equalData(a, b) {
|
|
|
11
11
|
return keys.length === Object.keys(right).length
|
|
12
12
|
&& keys.every(key => Object.hasOwn(right, key) && equalData(left[key], right[key]));
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
14
|
+
/** Only internally copied, deeply frozen data may bypass later descriptor checks. */
|
|
15
15
|
const snapshots = new WeakSet();
|
|
16
16
|
export function isSnapshot(value) { return snapshots.has(value); }
|
|
17
|
-
export function snapshot(value) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
export function snapshot(value, reject = message => { throw new TypeError(message); }) {
|
|
18
|
+
const ancestors = new Set();
|
|
19
|
+
const copies = new WeakMap();
|
|
20
|
+
const copy = (value, path) => {
|
|
21
|
+
if (!value || typeof value !== 'object')
|
|
22
|
+
return value;
|
|
23
|
+
if (snapshots.has(value))
|
|
24
|
+
return value;
|
|
25
|
+
if (ancestors.has(value))
|
|
26
|
+
return reject('Cyclic protocol data', path);
|
|
27
|
+
const existing = copies.get(value);
|
|
28
|
+
if (existing)
|
|
29
|
+
return existing;
|
|
30
|
+
const array = Array.isArray(value);
|
|
31
|
+
if (!array && ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
|
|
32
|
+
return reject('Expected plain data object', path);
|
|
33
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
34
|
+
const length = array ? descriptors.length.value : 0;
|
|
35
|
+
const keys = Reflect.ownKeys(descriptors);
|
|
36
|
+
if (array && keys.length !== length + 1)
|
|
37
|
+
return reject('Expected dense array without extra properties', path);
|
|
38
|
+
const result = array ? [] : {};
|
|
39
|
+
ancestors.add(value);
|
|
40
|
+
for (const key of keys) {
|
|
41
|
+
if (array && key === 'length')
|
|
42
|
+
continue;
|
|
43
|
+
const property = path ? `${path}.${String(key)}` : String(key);
|
|
44
|
+
if (typeof key !== 'string')
|
|
45
|
+
return reject('Symbols are not protocol data', property);
|
|
46
|
+
const descriptor = descriptors[key];
|
|
47
|
+
if (!descriptor.enumerable || !('value' in descriptor))
|
|
48
|
+
return reject('Accessors or non-enumerable properties are not protocol data', property);
|
|
49
|
+
if (array && (!/^(0|[1-9]\d*)$/.test(key) || Number(key) >= length))
|
|
50
|
+
return reject('Expected dense array index', property);
|
|
51
|
+
Object.defineProperty(result, key, { value: copy(descriptor.value, property), enumerable: true, writable: true, configurable: true });
|
|
52
|
+
}
|
|
53
|
+
ancestors.delete(value);
|
|
54
|
+
Object.freeze(result);
|
|
55
|
+
snapshots.add(result);
|
|
56
|
+
copies.set(value, result);
|
|
57
|
+
return result;
|
|
58
|
+
};
|
|
59
|
+
return copy(value, '');
|
|
26
60
|
}
|
|
27
61
|
//# sourceMappingURL=data.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { equalData, snapshot } from './data.js';
|
|
2
|
-
import { HYUIError } from './validation.js';
|
|
2
|
+
import { HYUIError, snapshotProtocolData } from './validation.js';
|
|
3
3
|
/** Backend-owned resource lifetime. No GPU acquire/present or platform handles in page state. */
|
|
4
4
|
export class HYPlatformViewController {
|
|
5
5
|
factory;
|
|
@@ -29,7 +29,12 @@ export class HYPlatformViewController {
|
|
|
29
29
|
this.#view.visible(this.shown && !this.#suspended);
|
|
30
30
|
}
|
|
31
31
|
catch (error) {
|
|
32
|
-
|
|
32
|
+
try {
|
|
33
|
+
this.dispose();
|
|
34
|
+
}
|
|
35
|
+
catch (cleanup) {
|
|
36
|
+
throw new AggregateError([error, cleanup], 'PlatformView initialization and cleanup failed', { cause: error });
|
|
37
|
+
}
|
|
33
38
|
throw error;
|
|
34
39
|
}
|
|
35
40
|
}
|
|
@@ -45,6 +50,7 @@ export class HYPlatformViewController {
|
|
|
45
50
|
layout(bounds) {
|
|
46
51
|
if (this.#disposed)
|
|
47
52
|
return;
|
|
53
|
+
bounds = snapshotProtocolData(bounds);
|
|
48
54
|
if (![bounds.x, bounds.y, bounds.width, bounds.height, bounds.scale].every(Number.isFinite)
|
|
49
55
|
|| bounds.width < 0 || bounds.height < 0 || bounds.scale <= 0)
|
|
50
56
|
throw new HYUIError('invalid-props', 'Invalid PlatformView bounds');
|
package/dist/core/selection.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { equalData
|
|
2
|
-
import { HYUIError, hyKey,
|
|
1
|
+
import { equalData } from './data.js';
|
|
2
|
+
import { HYUIError, hyKey, snapshotValidatedProps } from './validation.js';
|
|
3
3
|
/** Controlled Select/Tabs semantics. Views report user actions, never delayed setter echoes. */
|
|
4
4
|
export class HYSelectionController {
|
|
5
5
|
key;
|
|
@@ -22,10 +22,10 @@ export class HYSelectionController {
|
|
|
22
22
|
update(props) {
|
|
23
23
|
if (this.#disposed)
|
|
24
24
|
return;
|
|
25
|
-
|
|
25
|
+
props = snapshotValidatedProps('Select', props, { key: this.key });
|
|
26
26
|
if (equalData(props, this.#props))
|
|
27
27
|
return;
|
|
28
|
-
this.#props =
|
|
28
|
+
this.#props = props;
|
|
29
29
|
this.#generation++;
|
|
30
30
|
this.#apply();
|
|
31
31
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Exhaustive semantic focus policy, independent of any platform's control implementation. */
|
|
2
|
+
export declare const componentInteraction: Readonly<{
|
|
3
|
+
Row: false;
|
|
4
|
+
Column: false;
|
|
5
|
+
Grid: false;
|
|
6
|
+
Overlay: false;
|
|
7
|
+
Scroll: false;
|
|
8
|
+
Text: false;
|
|
9
|
+
Image: false;
|
|
10
|
+
Icon: false;
|
|
11
|
+
Badge: false;
|
|
12
|
+
Divider: false;
|
|
13
|
+
FormGroup: false;
|
|
14
|
+
Button: true;
|
|
15
|
+
Checkbox: true;
|
|
16
|
+
Toggle: true;
|
|
17
|
+
RadioGroup: true;
|
|
18
|
+
Rate: true;
|
|
19
|
+
Select: true;
|
|
20
|
+
Tabs: true;
|
|
21
|
+
TextInput: true;
|
|
22
|
+
TextArea: true;
|
|
23
|
+
Slider: true;
|
|
24
|
+
Dialog: false;
|
|
25
|
+
PlatformView: true;
|
|
26
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Exhaustive semantic focus policy, independent of any platform's control implementation. */
|
|
2
|
+
export const componentInteraction = Object.freeze({
|
|
3
|
+
Row: false, Column: false, Grid: false, Overlay: false, Scroll: false,
|
|
4
|
+
Text: false, Image: false, Icon: false, Badge: false, Divider: false, FormGroup: false,
|
|
5
|
+
Button: true, Checkbox: true, Toggle: true, RadioGroup: true, Rate: true,
|
|
6
|
+
Select: true, Tabs: true, TextInput: true, TextArea: true, Slider: true, Dialog: false, PlatformView: true,
|
|
7
|
+
});
|
|
8
|
+
//# sourceMappingURL=semantics.js.map
|
package/dist/core/text.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { equalData, snapshot } from './data.js';
|
|
2
|
-
import { HYUIError, hyKey,
|
|
2
|
+
import { HYUIError, hyKey, snapshotValidatedProps } from './validation.js';
|
|
3
3
|
/** Local draft/IME state only. The application accepts or rejects commit through props/revision. */
|
|
4
4
|
export class HYTextController {
|
|
5
5
|
key;
|
|
@@ -28,7 +28,7 @@ export class HYTextController {
|
|
|
28
28
|
update(props, revision = this.#revision) {
|
|
29
29
|
if (this.#disposed)
|
|
30
30
|
return;
|
|
31
|
-
|
|
31
|
+
props = snapshotValidatedProps(this.multiline ? 'TextArea' : 'TextInput', props, { key: this.key });
|
|
32
32
|
if (!Number.isSafeInteger(revision) || revision < 0)
|
|
33
33
|
throw new HYUIError('invalid-props', 'Invalid application revision', { key: this.key });
|
|
34
34
|
if (revision < this.#revision)
|
|
@@ -36,7 +36,7 @@ export class HYTextController {
|
|
|
36
36
|
const changed = !this.#props || props.value !== this.#props.value;
|
|
37
37
|
if (this.#props && changed && revision === this.#revision)
|
|
38
38
|
throw new HYUIError('invalid-props', 'Changed accepted value requires a newer revision', { key: this.key });
|
|
39
|
-
this.#props =
|
|
39
|
+
this.#props = props;
|
|
40
40
|
this.#revision = revision;
|
|
41
41
|
if (changed) {
|
|
42
42
|
if (this.#composing)
|
|
@@ -6,10 +6,12 @@ export declare class HYUIError extends Error {
|
|
|
6
6
|
}
|
|
7
7
|
export declare const HY_FEATURES: readonly HYFeature[];
|
|
8
8
|
export declare const HY_COMPONENTS: readonly HYComponentKind[];
|
|
9
|
+
/** Internal descriptor-safe handoff: validation and consumers see the same immutable values. */
|
|
10
|
+
export declare function snapshotProtocolData<T>(value: T, context?: HYDiagnosticContext): T;
|
|
9
11
|
export declare function hyValidateCapabilities(capabilities: HYCapabilities): void;
|
|
10
12
|
export declare function hySupports(capabilities: HYCapabilities, feature: HYFeature): boolean;
|
|
11
13
|
/** Internal immutable hand-off. Mutable and merely shallow-frozen inputs are always validated. */
|
|
12
|
-
export declare function snapshotValidatedProps<K extends HYComponentKind>(kind: K, props: HYComponentProps[K], context: HYDiagnosticContext, capabilities
|
|
14
|
+
export declare function snapshotValidatedProps<K extends HYComponentKind>(kind: K, props: HYComponentProps[K], context: HYDiagnosticContext, capabilities?: HYCapabilities): HYComponentProps[K];
|
|
13
15
|
export declare function hyValidateProps<K extends HYComponentKind>(kind: K, props: HYComponentProps[K], context?: HYDiagnosticContext, capabilities?: HYCapabilities): void;
|
|
14
16
|
/** Escaped, stable backend key. Author keys are unique across all slots of one parent. */
|
|
15
17
|
export declare function hyKey(...parts: readonly string[]): string;
|
package/dist/core/validation.js
CHANGED
|
@@ -97,16 +97,26 @@ const schemas = {
|
|
|
97
97
|
PlatformView: shape({ ...common, slot: name, resourceId: name }, ['slot', 'resourceId']),
|
|
98
98
|
};
|
|
99
99
|
export const HY_COMPONENTS = Object.freeze(Object.keys(schemas));
|
|
100
|
+
const validatedCapabilities = new WeakSet();
|
|
101
|
+
/** Internal descriptor-safe handoff: validation and consumers see the same immutable values. */
|
|
102
|
+
export function snapshotProtocolData(value, context = {}) {
|
|
103
|
+
return snapshot(value, (message, property) => fail(message, property ? field(context, property) : context));
|
|
104
|
+
}
|
|
100
105
|
export function hyValidateCapabilities(capabilities) {
|
|
101
106
|
const context = { property: 'capabilities' };
|
|
107
|
+
capabilities = snapshotProtocolData(capabilities, context);
|
|
108
|
+
if (validatedCapabilities.has(capabilities))
|
|
109
|
+
return;
|
|
102
110
|
shape({ contract: choice(1), backend: choice('web', 'nativescript', 'desktop'), components: list(choice(...HY_COMPONENTS)),
|
|
103
111
|
features: list((v, c) => { if (!HY_FEATURES.includes(v))
|
|
104
112
|
throw new HYUIError('capability', 'Unknown capability', c); }) }, ['contract', 'backend', 'components', 'features'])(capabilities, context);
|
|
105
113
|
if (new Set(capabilities.components).size !== capabilities.components.length || new Set(capabilities.features).size !== capabilities.features.length) {
|
|
106
114
|
throw new HYUIError('capability', 'Duplicate capability declaration', context);
|
|
107
115
|
}
|
|
116
|
+
validatedCapabilities.add(capabilities);
|
|
108
117
|
}
|
|
109
118
|
export function hySupports(capabilities, feature) {
|
|
119
|
+
capabilities = snapshotProtocolData(capabilities, { property: 'capabilities' });
|
|
110
120
|
hyValidateCapabilities(capabilities);
|
|
111
121
|
if (!HY_FEATURES.includes(feature))
|
|
112
122
|
throw new HYUIError('capability', 'Unknown capability', { property: feature });
|
|
@@ -123,12 +133,17 @@ function remember(props, kind) {
|
|
|
123
133
|
}
|
|
124
134
|
/** Internal immutable hand-off. Mutable and merely shallow-frozen inputs are always validated. */
|
|
125
135
|
export function snapshotValidatedProps(kind, props, context, capabilities) {
|
|
136
|
+
props = snapshotProtocolData(props, context);
|
|
126
137
|
hyValidateProps(kind, props, context, capabilities);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return result;
|
|
138
|
+
remember(props, kind);
|
|
139
|
+
return props;
|
|
130
140
|
}
|
|
131
141
|
export function hyValidateProps(kind, props, context = {}, capabilities) {
|
|
142
|
+
props = snapshotProtocolData(props, context);
|
|
143
|
+
if (capabilities) {
|
|
144
|
+
capabilities = snapshotProtocolData(capabilities, { property: 'capabilities' });
|
|
145
|
+
hyValidateCapabilities(capabilities);
|
|
146
|
+
}
|
|
132
147
|
if (!Object.hasOwn(schemas, kind))
|
|
133
148
|
fail('Unknown component kind', context);
|
|
134
149
|
if (!validatedSnapshots.get(props)?.has(kind)) {
|
|
@@ -181,8 +196,11 @@ export function hyKey(...parts) {
|
|
|
181
196
|
return '/' + parts.map(key => key.replace(/~/g, '~0').replace(/\//g, '~1')).join('/');
|
|
182
197
|
}
|
|
183
198
|
export function hyValidateNode(node, capabilities) {
|
|
184
|
-
if (capabilities)
|
|
199
|
+
if (capabilities) {
|
|
200
|
+
capabilities = snapshotProtocolData(capabilities, { property: 'capabilities' });
|
|
185
201
|
hyValidateCapabilities(capabilities);
|
|
202
|
+
}
|
|
203
|
+
node = snapshotProtocolData(node, { property: 'node' });
|
|
186
204
|
const ancestors = new Set();
|
|
187
205
|
const walk = (value, parent) => {
|
|
188
206
|
const raw = record(value, { property: 'node' });
|
|
@@ -238,6 +256,6 @@ export function hyValidateNode(node, capabilities) {
|
|
|
238
256
|
return snapshot(node);
|
|
239
257
|
}
|
|
240
258
|
export function hyNode(kind, key, props, content = {}) {
|
|
241
|
-
return hyValidateNode({ kind, key, props, ...content });
|
|
259
|
+
return hyValidateNode({ kind, key, props, ...snapshotProtocolData(content, { key }) });
|
|
242
260
|
}
|
|
243
261
|
//# sourceMappingURL=validation.js.map
|
package/dist/date-picker.js
CHANGED
|
@@ -191,6 +191,10 @@ export class HYDatePicker extends HTMLElement {
|
|
|
191
191
|
return new Intl.DateTimeFormat(this.locale, { year: 'numeric', month: 'short', day: 'numeric' }).format(date);
|
|
192
192
|
}
|
|
193
193
|
_render() {
|
|
194
|
+
if (this.disabled && this.open) {
|
|
195
|
+
this.open = false;
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
194
198
|
const text = this._formatDate(this._value);
|
|
195
199
|
this._label.textContent = text || this.placeholder;
|
|
196
200
|
this._label.classList.toggle('placeholder', !text);
|
|
@@ -327,6 +331,8 @@ export class HYDatePicker extends HTMLElement {
|
|
|
327
331
|
else
|
|
328
332
|
this._panel.querySelector('.day:not(:disabled)')?.focus(); }
|
|
329
333
|
_commit(value) {
|
|
334
|
+
if (this.disabled)
|
|
335
|
+
return;
|
|
330
336
|
this._value = this._normalizeValue(value);
|
|
331
337
|
this._reflectValue();
|
|
332
338
|
if (this.open)
|