@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/dist/dialog.d.ts
CHANGED
|
@@ -9,9 +9,12 @@ export declare class HYDialog extends HTMLElement {
|
|
|
9
9
|
private readonly _closeButton;
|
|
10
10
|
private _returnFocus;
|
|
11
11
|
private _closeReason;
|
|
12
|
+
private _shown;
|
|
13
|
+
private _session;
|
|
12
14
|
static get observedAttributes(): string[];
|
|
13
15
|
constructor();
|
|
14
16
|
connectedCallback(): void;
|
|
17
|
+
disconnectedCallback(): void;
|
|
15
18
|
attributeChangedCallback(name: string): void;
|
|
16
19
|
get open(): boolean;
|
|
17
20
|
set open(value: boolean);
|
|
@@ -26,6 +29,7 @@ export declare class HYDialog extends HTMLElement {
|
|
|
26
29
|
close(reason?: HYDialogCloseDetail['reason']): void;
|
|
27
30
|
private _syncHeading;
|
|
28
31
|
private _syncOpen;
|
|
32
|
+
private _finishClose;
|
|
29
33
|
private _onCancel;
|
|
30
34
|
private _onDialogClick;
|
|
31
35
|
private _requestClose;
|
package/dist/dialog.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { focusedElement } from './internal/focus.js';
|
|
1
2
|
/** Accessible modal surface with slotted body/footer content and reflected open state. */
|
|
2
3
|
export class HYDialog extends HTMLElement {
|
|
3
4
|
_dialog = document.createElement('dialog');
|
|
@@ -5,6 +6,8 @@ export class HYDialog extends HTMLElement {
|
|
|
5
6
|
_closeButton = document.createElement('button');
|
|
6
7
|
_returnFocus = null;
|
|
7
8
|
_closeReason = 'programmatic';
|
|
9
|
+
_shown = false;
|
|
10
|
+
_session = 0;
|
|
8
11
|
static get observedAttributes() {
|
|
9
12
|
return ['open', 'heading', 'dismissible', 'controlled'];
|
|
10
13
|
}
|
|
@@ -109,6 +112,14 @@ export class HYDialog extends HTMLElement {
|
|
|
109
112
|
this._syncHeading();
|
|
110
113
|
this._syncOpen();
|
|
111
114
|
}
|
|
115
|
+
disconnectedCallback() {
|
|
116
|
+
this._shown = false;
|
|
117
|
+
this._session++;
|
|
118
|
+
this._returnFocus = null;
|
|
119
|
+
this._closeReason = 'programmatic';
|
|
120
|
+
if (this._dialog.open)
|
|
121
|
+
this._dialog.close();
|
|
122
|
+
}
|
|
112
123
|
attributeChangedCallback(name) {
|
|
113
124
|
if (name === 'heading')
|
|
114
125
|
this._syncHeading();
|
|
@@ -127,7 +138,7 @@ export class HYDialog extends HTMLElement {
|
|
|
127
138
|
showModal() {
|
|
128
139
|
if (this.open && this._dialog.open)
|
|
129
140
|
return;
|
|
130
|
-
this._returnFocus =
|
|
141
|
+
this._returnFocus = focusedElement(this.ownerDocument);
|
|
131
142
|
this._closeReason = 'programmatic';
|
|
132
143
|
this.open = true;
|
|
133
144
|
}
|
|
@@ -142,12 +153,32 @@ export class HYDialog extends HTMLElement {
|
|
|
142
153
|
}
|
|
143
154
|
_syncOpen() {
|
|
144
155
|
if (this.open && !this._dialog.open) {
|
|
145
|
-
this._returnFocus ??=
|
|
146
|
-
this.
|
|
156
|
+
this._returnFocus ??= focusedElement(this.ownerDocument);
|
|
157
|
+
this._shown = true;
|
|
158
|
+
this._session++;
|
|
159
|
+
try {
|
|
160
|
+
this._dialog.showModal();
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
this._shown = false;
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
147
166
|
return;
|
|
148
167
|
}
|
|
149
|
-
if (!this.open && this.
|
|
168
|
+
if (!this.open && this._shown)
|
|
169
|
+
this._finishClose();
|
|
170
|
+
}
|
|
171
|
+
_finishClose() {
|
|
172
|
+
const session = this._session, reason = this._closeReason, returnFocus = this._returnFocus, controlled = this.controlled;
|
|
173
|
+
this._shown = false;
|
|
174
|
+
this._returnFocus = null;
|
|
175
|
+
this._closeReason = 'programmatic';
|
|
176
|
+
this.removeAttribute('open');
|
|
177
|
+
if (this._dialog.open)
|
|
150
178
|
this._dialog.close();
|
|
179
|
+
this.dispatchEvent(new CustomEvent('dialog-close', { detail: { reason }, bubbles: true, composed: true }));
|
|
180
|
+
if (session === this._session && !this.open && this.isConnected && !controlled && returnFocus?.isConnected)
|
|
181
|
+
returnFocus.focus();
|
|
151
182
|
}
|
|
152
183
|
_onCancel = (event) => {
|
|
153
184
|
event.preventDefault();
|
|
@@ -179,19 +210,9 @@ export class HYDialog extends HTMLElement {
|
|
|
179
210
|
}
|
|
180
211
|
_onNativeClose = () => {
|
|
181
212
|
// Native close is queued. A subsequent showModal must not be undone by that old event.
|
|
182
|
-
if (this._dialog.open)
|
|
213
|
+
if (!this.isConnected || this._dialog.open || !this._shown)
|
|
183
214
|
return;
|
|
184
|
-
this.
|
|
185
|
-
const reason = this._closeReason;
|
|
186
|
-
this._closeReason = 'programmatic';
|
|
187
|
-
this.dispatchEvent(new CustomEvent('dialog-close', {
|
|
188
|
-
detail: { reason },
|
|
189
|
-
bubbles: true,
|
|
190
|
-
composed: true,
|
|
191
|
-
}));
|
|
192
|
-
if (!this.controlled)
|
|
193
|
-
this._returnFocus?.focus();
|
|
194
|
-
this._returnFocus = null;
|
|
215
|
+
this._finishClose();
|
|
195
216
|
};
|
|
196
217
|
}
|
|
197
218
|
export function defineDialogComponents() {
|
package/dist/draggable.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { finiteNumber as readFiniteNumber } from './internal/numbers.js';
|
|
2
|
+
import { isKeyboardControlEvent } from './internal/keyboard.js';
|
|
1
3
|
const DEFAULT_CANCEL = 'input, textarea, select, button, a, [contenteditable="true"], [data-no-drag]';
|
|
2
4
|
function finiteNumber(value, fallback = 0) {
|
|
3
|
-
const number =
|
|
5
|
+
const number = readFiniteNumber(value, fallback);
|
|
4
6
|
return Number.isFinite(number) ? number : fallback;
|
|
5
7
|
}
|
|
6
8
|
function safeMatches(element, selector) {
|
|
@@ -164,7 +166,7 @@ export class HYDraggable extends HTMLElement {
|
|
|
164
166
|
this._completePointerDrag(this._pointerId, cancelled);
|
|
165
167
|
}
|
|
166
168
|
_handleKeydown(event) {
|
|
167
|
-
if (this.disabled || !this.keyboard)
|
|
169
|
+
if (this.disabled || !this.keyboard || event.defaultPrevented || isKeyboardControlEvent(event, this._surface))
|
|
168
170
|
return;
|
|
169
171
|
const multiplier = event.shiftKey ? 10 : 1;
|
|
170
172
|
const step = this.grid * multiplier;
|
package/dist/drawer.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
+
import { focusedElement, focusableElements } from './internal/focus.js';
|
|
1
2
|
const CONTENT_DESTROY_DELAY = 220;
|
|
2
|
-
const FOCUSABLE_SELECTOR = [
|
|
3
|
-
'a[href]',
|
|
4
|
-
'button:not([disabled])',
|
|
5
|
-
'input:not([disabled])',
|
|
6
|
-
'select:not([disabled])',
|
|
7
|
-
'textarea:not([disabled])',
|
|
8
|
-
'[tabindex]:not([tabindex="-1"])',
|
|
9
|
-
].join(',');
|
|
10
3
|
const DRAWER_STYLES = `
|
|
11
4
|
:host {
|
|
12
5
|
position: fixed;
|
|
@@ -278,7 +271,7 @@ export class HYDrawer extends HTMLElement {
|
|
|
278
271
|
if (this.open) {
|
|
279
272
|
this._cancelContentDestroy();
|
|
280
273
|
this._restoreContent();
|
|
281
|
-
this._returnFocus ??=
|
|
274
|
+
this._returnFocus ??= focusedElement(this.ownerDocument);
|
|
282
275
|
this._panel.setAttribute('aria-hidden', 'false');
|
|
283
276
|
this._syncPanelSemantics();
|
|
284
277
|
this._attachDocumentListener();
|
|
@@ -329,14 +322,13 @@ export class HYDrawer extends HTMLElement {
|
|
|
329
322
|
}
|
|
330
323
|
if (event.key !== 'Tab' || !this.mask)
|
|
331
324
|
return;
|
|
332
|
-
const focusable =
|
|
333
|
-
.filter(element => !element.hidden && element.getAttribute('aria-hidden') !== 'true');
|
|
325
|
+
const focusable = focusableElements(this._panel);
|
|
334
326
|
if (focusable.length === 0) {
|
|
335
327
|
event.preventDefault();
|
|
336
328
|
this._panel.focus();
|
|
337
329
|
return;
|
|
338
330
|
}
|
|
339
|
-
const active = this.
|
|
331
|
+
const active = focusedElement(this.ownerDocument);
|
|
340
332
|
const index = focusable.indexOf(active);
|
|
341
333
|
if (event.shiftKey && index <= 0) {
|
|
342
334
|
event.preventDefault();
|
package/dist/dropdown.js
CHANGED
package/dist/input.js
CHANGED
|
@@ -192,9 +192,9 @@ export class HYInput extends HTMLElement {
|
|
|
192
192
|
if (this._input.required !== this.hasAttribute('required'))
|
|
193
193
|
this._input.required = this.hasAttribute('required');
|
|
194
194
|
this._searchButton.hidden = type !== 'search';
|
|
195
|
-
this._searchButton.disabled =
|
|
195
|
+
this._searchButton.disabled = disabled;
|
|
196
196
|
this._searchButton.setAttribute('aria-label', this.searchLabel);
|
|
197
|
-
this._control.classList.toggle('disabled',
|
|
197
|
+
this._control.classList.toggle('disabled', disabled);
|
|
198
198
|
this._control.classList.toggle('readonly', this.readOnly);
|
|
199
199
|
this._syncAffixes();
|
|
200
200
|
this._syncValidity();
|
|
@@ -237,7 +237,7 @@ export class HYInput extends HTMLElement {
|
|
|
237
237
|
};
|
|
238
238
|
_onSearchClick = () => { this._emitSearch('button'); };
|
|
239
239
|
_emitSearch(source) {
|
|
240
|
-
if (this.disabled || this.type !== 'search')
|
|
240
|
+
if (this.disabled || this._formControl.disabled || this.type !== 'search')
|
|
241
241
|
return false;
|
|
242
242
|
return this.dispatchEvent(new CustomEvent('search', {
|
|
243
243
|
detail: { value: this._input.value, valid: this.valid, source },
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function focusedElement(document) {
|
|
2
|
+
let element = document.activeElement;
|
|
3
|
+
while (element?.shadowRoot?.activeElement)
|
|
4
|
+
element = element.shadowRoot.activeElement;
|
|
5
|
+
return element instanceof HTMLElement ? element : null;
|
|
6
|
+
}
|
|
7
|
+
export function focusableElements(root) {
|
|
8
|
+
const result = [];
|
|
9
|
+
const visit = (element) => {
|
|
10
|
+
if (element instanceof HTMLElement && (element.hidden || element.inert || element.matches(':disabled')))
|
|
11
|
+
return;
|
|
12
|
+
const style = getComputedStyle(element);
|
|
13
|
+
if (style.display === 'none' || style.visibility === 'hidden')
|
|
14
|
+
return;
|
|
15
|
+
if (element instanceof HTMLSlotElement) {
|
|
16
|
+
const assigned = element.assignedElements({ flatten: true });
|
|
17
|
+
for (const child of assigned.length ? assigned : element.children)
|
|
18
|
+
visit(child);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (element instanceof HTMLElement && element.getClientRects().length &&
|
|
22
|
+
(element.tabIndex >= 0 || (element.isContentEditable && !element.hasAttribute('tabindex'))))
|
|
23
|
+
result.push(element);
|
|
24
|
+
for (const child of element.shadowRoot?.children ?? element.children)
|
|
25
|
+
visit(child);
|
|
26
|
+
};
|
|
27
|
+
for (const child of root.children)
|
|
28
|
+
visit(child);
|
|
29
|
+
return result.sort((a, b) => (a.tabIndex > 0 ? a.tabIndex : Infinity) - (b.tabIndex > 0 ? b.tabIndex : Infinity));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=focus.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const CONTROL_SELECTOR = 'input,textarea,select,button,a[href],summary,[role="textbox"],[role="combobox"],[role="spinbutton"],[role="slider"],[role="button"],[role="checkbox"],[role="radio"],[role="switch"],[role="listbox"]';
|
|
2
|
+
/** Ancestor shortcuts must leave slotted and shadow-owned controls their editing keys. */
|
|
3
|
+
export function isKeyboardControlEvent(event, boundary) {
|
|
4
|
+
for (const target of event.composedPath()) {
|
|
5
|
+
if (target === boundary)
|
|
6
|
+
break;
|
|
7
|
+
if (target instanceof HTMLElement && (target.isContentEditable || target.matches(CONTROL_SELECTOR)))
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=keyboard.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Missing and empty attributes use their default; an explicit zero remains a value. */
|
|
2
|
+
export function finiteNumber(value, fallback) {
|
|
3
|
+
if (value == null || typeof value === 'string' && !value.trim())
|
|
4
|
+
return fallback;
|
|
5
|
+
const number = Number(value);
|
|
6
|
+
return Number.isFinite(number) ? number : fallback;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=numbers.js.map
|
package/dist/modal.js
CHANGED
|
@@ -1,34 +1,5 @@
|
|
|
1
|
+
import { focusedElement, focusableElements } from './internal/focus.js';
|
|
1
2
|
const scrollLocks = new WeakMap();
|
|
2
|
-
function focusedElement(document) {
|
|
3
|
-
let element = document.activeElement;
|
|
4
|
-
while (element?.shadowRoot?.activeElement)
|
|
5
|
-
element = element.shadowRoot.activeElement;
|
|
6
|
-
return element instanceof HTMLElement ? element : null;
|
|
7
|
-
}
|
|
8
|
-
function focusableElements(root) {
|
|
9
|
-
const result = [];
|
|
10
|
-
const visit = (element) => {
|
|
11
|
-
if (element instanceof HTMLElement && (element.hidden || element.inert || element.matches(':disabled')))
|
|
12
|
-
return;
|
|
13
|
-
const style = getComputedStyle(element);
|
|
14
|
-
if (style.display === 'none' || style.visibility === 'hidden')
|
|
15
|
-
return;
|
|
16
|
-
if (element instanceof HTMLSlotElement) {
|
|
17
|
-
const assigned = element.assignedElements({ flatten: true });
|
|
18
|
-
for (const child of assigned.length ? assigned : element.children)
|
|
19
|
-
visit(child);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (element instanceof HTMLElement && element.getClientRects().length &&
|
|
23
|
-
(element.tabIndex >= 0 || (element.isContentEditable && !element.hasAttribute('tabindex'))))
|
|
24
|
-
result.push(element);
|
|
25
|
-
for (const child of element.shadowRoot?.children ?? element.children)
|
|
26
|
-
visit(child);
|
|
27
|
-
};
|
|
28
|
-
for (const child of root.children)
|
|
29
|
-
visit(child);
|
|
30
|
-
return result.sort((a, b) => (a.tabIndex > 0 ? a.tabIndex : Infinity) - (b.tabIndex > 0 ? b.tabIndex : Infinity));
|
|
31
|
-
}
|
|
32
3
|
/** A native modal with default actions, async confirmation support and slotted content. */
|
|
33
4
|
export class HYModal extends HTMLElement {
|
|
34
5
|
_dialog = document.createElement('dialog');
|
package/dist/notification.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { finiteNumber } from './internal/numbers.js';
|
|
1
2
|
const DEFAULT_DURATION = 4.5;
|
|
2
3
|
const DEFAULT_PLACEMENT = 'topRight';
|
|
3
4
|
const EXIT_DURATION = 170;
|
|
@@ -187,7 +188,7 @@ export class HYNotification extends HTMLElement {
|
|
|
187
188
|
this.setAttribute('placement', isPlacement(value) ? value : DEFAULT_PLACEMENT);
|
|
188
189
|
}
|
|
189
190
|
get duration() {
|
|
190
|
-
const value =
|
|
191
|
+
const value = finiteNumber(this.getAttribute('duration'), DEFAULT_DURATION);
|
|
191
192
|
return Number.isFinite(value) && value >= 0 ? value : DEFAULT_DURATION;
|
|
192
193
|
}
|
|
193
194
|
set duration(value) {
|
package/dist/portable/page.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HYUIError, hyValidateCapabilities, hyValidateNode, hyValidateProps, snapshotValidatedProps } from '../core/validation.js';
|
|
2
|
-
import { equalData
|
|
1
|
+
import { HYUIError, hyValidateCapabilities, hyValidateNode, hyValidateProps, snapshotValidatedProps, snapshotProtocolData } from '../core/validation.js';
|
|
2
|
+
import { equalData } from '../core/data.js';
|
|
3
|
+
import { componentInteraction } from '../core/semantics.js';
|
|
3
4
|
import { diff, flatten } from './tree.js';
|
|
4
|
-
const interactive = new Set(['Button', 'Toggle', 'Select', 'Tabs', 'TextInput', 'TextArea', 'Slider', 'PlatformView']);
|
|
5
5
|
/** A synchronous, bounded page reconciler. It owns bindings/rendering, never the application store. */
|
|
6
6
|
export class HYPage {
|
|
7
7
|
options;
|
|
@@ -21,13 +21,15 @@ export class HYPage {
|
|
|
21
21
|
#subscriptions = new Set();
|
|
22
22
|
#focused;
|
|
23
23
|
#boundStores = new Set();
|
|
24
|
+
#frames = [];
|
|
24
25
|
#openers = new Map();
|
|
25
26
|
#cancelTransaction = 0;
|
|
26
27
|
constructor(renderer, options = {}) {
|
|
27
28
|
this.options = options;
|
|
28
|
-
|
|
29
|
+
const capabilities = snapshotProtocolData(renderer.capabilities, { property: 'capabilities' });
|
|
30
|
+
hyValidateCapabilities(capabilities);
|
|
29
31
|
this.#renderer = renderer;
|
|
30
|
-
this.#capabilities =
|
|
32
|
+
this.#capabilities = capabilities;
|
|
31
33
|
}
|
|
32
34
|
get status() { return this.#status; }
|
|
33
35
|
get revision() { return this.#revision; }
|
|
@@ -73,9 +75,12 @@ export class HYPage {
|
|
|
73
75
|
throw new HYUIError('invalid-props', 'Binding target missing or kind changed', { key });
|
|
74
76
|
const context = { key, ...(entry.node.source ? { source: entry.node.source } : {}) };
|
|
75
77
|
const accepted = snapshotValidatedProps(kind, props, context, this.#capabilities);
|
|
76
|
-
if (equalData(entry.node.props,
|
|
78
|
+
if (equalData(entry.node.props, accepted))
|
|
77
79
|
return;
|
|
78
|
-
const
|
|
80
|
+
const frame = this.#frames.at(-1);
|
|
81
|
+
const next = frame?.draft === this.#desired ? frame.draft : new Map(this.#desired);
|
|
82
|
+
if (frame)
|
|
83
|
+
frame.draft = next;
|
|
79
84
|
next.set(key, { ...entry, node: Object.freeze({ ...entry.node, props: accepted }) });
|
|
80
85
|
this.#desired = next;
|
|
81
86
|
this.#updates?.add(key);
|
|
@@ -85,6 +90,7 @@ export class HYPage {
|
|
|
85
90
|
this.#assertMutable();
|
|
86
91
|
const before = this.#desired, updates = this.#updates && new Set(this.#updates);
|
|
87
92
|
this.#depth++;
|
|
93
|
+
this.#frames.push({});
|
|
88
94
|
try {
|
|
89
95
|
const result = run();
|
|
90
96
|
if (result && typeof result.then === 'function')
|
|
@@ -97,7 +103,11 @@ export class HYPage {
|
|
|
97
103
|
}
|
|
98
104
|
finally {
|
|
99
105
|
this.#depth--;
|
|
106
|
+
this.#frames.pop();
|
|
100
107
|
}
|
|
108
|
+
const parent = this.#frames.at(-1);
|
|
109
|
+
if (parent && this.#desired !== before)
|
|
110
|
+
parent.draft = this.#desired;
|
|
101
111
|
this.#flush();
|
|
102
112
|
}
|
|
103
113
|
/** One store subscription: a store transaction produces one final page batch across all bindings. */
|
|
@@ -108,7 +118,7 @@ export class HYPage {
|
|
|
108
118
|
const definitions = [...bindings];
|
|
109
119
|
if (new Set(definitions.map(b => b.key)).size !== definitions.length)
|
|
110
120
|
throw new HYUIError('duplicate-key', 'Duplicate binding target');
|
|
111
|
-
const select = (state) => definitions.map(b => b.select(state));
|
|
121
|
+
const select = (state) => definitions.map(b => snapshotValidatedProps(b.kind, b.select(state), { key: b.key }, this.#capabilities));
|
|
112
122
|
const equal = (a, b) => a.every((p, i) => (definitions[i].equal ?? equalData)(p, b[i]));
|
|
113
123
|
let applied = [];
|
|
114
124
|
const apply = (props) => {
|
|
@@ -119,7 +129,7 @@ export class HYPage {
|
|
|
119
129
|
// A grouped subscription does not make every binding dirty. Reuse a
|
|
120
130
|
// previously validated result only while its target is still unchanged.
|
|
121
131
|
// External render/setProps and failed transactions invalidate this path.
|
|
122
|
-
if (node === applied[i] && node && equalData(node.props, props[i]))
|
|
132
|
+
if (node === applied[i] && node && (binding.equal ?? equalData)(node.props, props[i]))
|
|
123
133
|
return;
|
|
124
134
|
this.setProps(binding.key, binding.kind, props[i]);
|
|
125
135
|
}));
|
|
@@ -217,7 +227,7 @@ export class HYPage {
|
|
|
217
227
|
}
|
|
218
228
|
#inside(key, parent) { return key === parent || key.startsWith(`${parent}/`); }
|
|
219
229
|
#dialogTarget(key) {
|
|
220
|
-
return [...this.#rendered].find(([id, entry]) => this.#inside(id, key) &&
|
|
230
|
+
return [...this.#rendered].find(([id, entry]) => this.#inside(id, key) && componentInteraction[entry.node.kind] && this.#available(id))?.[0] ?? key;
|
|
221
231
|
}
|
|
222
232
|
#restoreFocus(previous) {
|
|
223
233
|
const oldDialogs = this.#dialogs(previous), dialogs = this.#dialogs(this.#rendered);
|
|
@@ -309,17 +319,18 @@ export class HYPage {
|
|
|
309
319
|
throw new HYUIError('lifecycle', 'Only a faulted page may rebuild');
|
|
310
320
|
if (renderer === this.#renderer)
|
|
311
321
|
throw new HYUIError('lifecycle', 'Rebuild needs a fresh renderer');
|
|
312
|
-
|
|
322
|
+
const capabilities = snapshotProtocolData(renderer.capabilities, { property: 'capabilities' });
|
|
323
|
+
hyValidateCapabilities(capabilities);
|
|
313
324
|
for (const [key, entry] of this.#desired) {
|
|
314
|
-
hyValidateProps(entry.node.kind, entry.node.props, { key },
|
|
325
|
+
hyValidateProps(entry.node.kind, entry.node.props, { key }, capabilities);
|
|
315
326
|
for (const feature of entry.node.requires ?? [])
|
|
316
|
-
if (!
|
|
327
|
+
if (!capabilities.features.includes(feature))
|
|
317
328
|
throw new HYUIError('capability', `Missing capability ${feature}`, { key });
|
|
318
329
|
}
|
|
319
330
|
++this.#epoch;
|
|
320
331
|
this.#renderer.dispose();
|
|
321
332
|
this.#renderer = renderer;
|
|
322
|
-
this.#capabilities =
|
|
333
|
+
this.#capabilities = capabilities;
|
|
323
334
|
this.#rendered = new Map();
|
|
324
335
|
this.#updates = undefined;
|
|
325
336
|
this.#order.clear();
|
package/dist/radio.js
CHANGED
|
@@ -199,7 +199,7 @@ export class HYRadio extends HTMLElement {
|
|
|
199
199
|
? root.querySelectorAll(`hy-radio[name="${cssEscape(this.name)}"]`)
|
|
200
200
|
: [];
|
|
201
201
|
for (const peer of peers) {
|
|
202
|
-
if (peer === this || peer.
|
|
202
|
+
if (peer === this || peer.form !== this.form)
|
|
203
203
|
continue;
|
|
204
204
|
peer.removeAttribute('checked');
|
|
205
205
|
}
|
package/dist/resizable.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isKeyboardControlEvent } from './internal/keyboard.js';
|
|
1
2
|
const HANDLES = ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'];
|
|
2
3
|
const DEFAULT_CANCEL = 'input, textarea, select, button, a, [contenteditable="true"], [data-no-move]';
|
|
3
4
|
function finiteNumber(value, fallback) {
|
|
@@ -257,9 +258,11 @@ export class HYResizable extends HTMLElement {
|
|
|
257
258
|
this._finishPointer(this._pointerId, cancelled);
|
|
258
259
|
}
|
|
259
260
|
_handleKeydown(event) {
|
|
260
|
-
if (this.disabled || !this.keyboard)
|
|
261
|
+
if (this.disabled || !this.keyboard || event.defaultPrevented || isKeyboardControlEvent(event, this._frame))
|
|
261
262
|
return;
|
|
262
263
|
const handle = event.composedPath().find((node) => node instanceof HTMLElement && Boolean(node.dataset.resizeHandle))?.dataset.resizeHandle ?? 'move';
|
|
264
|
+
if (handle === 'move' && !this.movable)
|
|
265
|
+
return;
|
|
263
266
|
const step = this.grid * (event.shiftKey ? 10 : 1);
|
|
264
267
|
let deltaX = 0;
|
|
265
268
|
let deltaY = 0;
|
package/dist/table.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ export declare class HYTable<T extends object = Record<string, unknown>> extends
|
|
|
59
59
|
static get observedAttributes(): string[];
|
|
60
60
|
constructor();
|
|
61
61
|
connectedCallback(): void;
|
|
62
|
-
attributeChangedCallback(): void;
|
|
62
|
+
attributeChangedCallback(name?: string): void;
|
|
63
63
|
get columns(): readonly HYTableColumn<T>[];
|
|
64
64
|
set columns(value: readonly HYTableColumn<T>[]);
|
|
65
65
|
get dataSource(): readonly T[];
|
|
@@ -87,7 +87,9 @@ export declare class HYTable<T extends object = Record<string, unknown>> extends
|
|
|
87
87
|
setFilter(key: string, value: string): void;
|
|
88
88
|
clearFilters(): void;
|
|
89
89
|
private _syncAttributes;
|
|
90
|
+
private _update;
|
|
90
91
|
private _render;
|
|
92
|
+
private _syncHeaderState;
|
|
91
93
|
private _renderHeader;
|
|
92
94
|
private _createFilterMenu;
|
|
93
95
|
private _updateFilterFromControl;
|