@zeyos/zx 5.7.1 → 5.8.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.
- package/CHANGELOG.md +296 -0
- package/README.md +47 -9
- package/dist/types/components/activity-item/activity-item.d.ts +14 -3
- package/dist/types/components/agent-avatar/agent-avatar.d.ts +165 -0
- package/dist/types/components/agent-avatar/agent-face.d.ts +93 -0
- package/dist/types/components/agent-thread/ag-ui.d.ts +21 -9
- package/dist/types/components/agent-thread/agent-thread.d.ts +26 -0
- package/dist/types/components/agent-thread/ui-message-stream.d.ts +3 -1
- package/dist/types/components/approval-card/approval-card.d.ts +31 -2
- package/dist/types/components/aurora/aurora.d.ts +31 -5
- package/dist/types/components/calendar/calendar.d.ts +39 -26
- package/dist/types/components/chart/chart.d.ts +250 -20
- package/dist/types/components/chart/color.d.ts +66 -0
- package/dist/types/components/chart/svg-adapter.d.ts +103 -0
- package/dist/types/components/chart/svg-geometry.d.ts +203 -0
- package/dist/types/components/check-button/check-button.d.ts +1 -4
- package/dist/types/components/checklist/checklist.d.ts +19 -5
- package/dist/types/components/code-editor/code-editor.d.ts +55 -1
- package/dist/types/components/composer/composer.d.ts +41 -6
- package/dist/types/components/context-menu/context-menu.d.ts +36 -8
- package/dist/types/components/copy/copy-button.d.ts +6 -0
- package/dist/types/components/copy/copy-input.d.ts +1 -0
- package/dist/types/components/date-picker/date-picker.d.ts +14 -0
- package/dist/types/components/date-picker/time-picker.d.ts +26 -17
- package/dist/types/components/datebox/datebox.d.ts +8 -4
- package/dist/types/components/dialog/dialog.d.ts +13 -2
- package/dist/types/components/empty-state/empty-state.d.ts +10 -1
- package/dist/types/components/field/field.d.ts +4 -2
- package/dist/types/components/form/form.d.ts +2 -1
- package/dist/types/components/kanban-view/kanban-card.d.ts +7 -0
- package/dist/types/components/kanban-view/kanban-view.d.ts +15 -3
- package/dist/types/components/launcher/launcher.d.ts +26 -0
- package/dist/types/components/master-panel/master-panel.d.ts +9 -4
- package/dist/types/components/menu-button/menu-button.d.ts +29 -5
- package/dist/types/components/message/message.d.ts +308 -5
- package/dist/types/components/modal/modal.d.ts +11 -0
- package/dist/types/components/modal/native-dialog.d.ts +40 -0
- package/dist/types/components/module-bar/module-bar.d.ts +9 -2
- package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +5 -4
- package/dist/types/components/number-field/number-field.d.ts +7 -0
- package/dist/types/components/pagination/pagination.d.ts +341 -19
- package/dist/types/components/run-status/run-status.d.ts +26 -0
- package/dist/types/components/run-trace/run-trace.d.ts +10 -6
- package/dist/types/components/search/search.d.ts +16 -4
- package/dist/types/components/select/select.d.ts +19 -1
- package/dist/types/components/sheet/sheet.d.ts +18 -4
- package/dist/types/components/slider/slider.d.ts +2 -1
- package/dist/types/components/stat-tile/stat-tile.d.ts +20 -3
- package/dist/types/components/stepper/stepper.d.ts +17 -4
- package/dist/types/components/surface/catalog.d.ts +61 -17
- package/dist/types/components/surface/surface.d.ts +6 -4
- package/dist/types/components/table/table.d.ts +207 -5
- package/dist/types/components/table/window.d.ts +25 -1
- package/dist/types/components/toggle/toggle.d.ts +38 -6
- package/dist/types/components/tooltip/tooltip.d.ts +5 -4
- package/dist/types/components/tree/tree.d.ts +43 -6
- package/dist/types/components/truncate/truncate.d.ts +4 -2
- package/dist/types/components/value-list/value-list.d.ts +9 -2
- package/dist/types/core/date.d.ts +2 -1
- package/dist/types/core/drag-axis.d.ts +10 -5
- package/dist/types/core/export.d.ts +2 -2
- package/dist/types/core/format.d.ts +3 -1
- package/dist/types/core/icons.d.ts +36 -3
- package/dist/types/core/keyboard.d.ts +7 -3
- package/dist/types/core/messages.d.ts +3 -0
- package/dist/types/core/storage.d.ts +4 -3
- package/dist/types/core/util.d.ts +3 -1
- package/dist/types/elements/define.d.ts +5 -2
- package/dist/types/index.d.ts +6 -4
- package/dist/types/internal/agent-model.d.ts +99 -0
- package/dist/types/internal/app-rail.d.ts +37 -2
- package/dist/types/internal/collections.d.ts +18 -0
- package/dist/types/internal/menu-items.d.ts +27 -0
- package/dist/types/internal/overlay-content.d.ts +23 -0
- package/dist/types/internal/presence-loop.d.ts +5 -2
- package/dist/types/locales/index.d.ts +3 -0
- package/dist/types/zeyos/calendar.d.ts +43 -7
- package/dist/types/zeyos/connect.d.ts +4 -0
- package/dist/types/zeyos/form.d.ts +13 -5
- package/dist/types/zeyos/select.d.ts +5 -2
- package/dist/types/zeyos/table.d.ts +16 -8
- package/dist/types/zeyos/view.d.ts +2 -1
- package/dist/zx-zeyos.esm.js +2998 -451
- package/dist/zx-zeyos.esm.min.js +4 -4
- package/dist/zx.core.css +4 -0
- package/dist/zx.core.min.css +1 -1
- package/dist/zx.css +948 -48
- package/dist/zx.esm.js +7432 -3408
- package/dist/zx.esm.min.js +26 -26
- package/dist/zx.global.js +7432 -3408
- package/dist/zx.global.min.js +26 -26
- package/dist/zx.layered.css +950 -48
- package/dist/zx.layered.min.css +1 -1
- package/dist/zx.min.css +1 -1
- package/docs/agent-catalog.json +159 -1
- package/docs/agent-surfaces.md +21 -21
- package/docs/api.json +3122 -528
- package/docs/components/account-menu.md +24 -0
- package/docs/components/activity-item.md +23 -0
- package/docs/components/activity-list.md +28 -0
- package/docs/components/agent-avatar.md +59 -0
- package/docs/components/agent-thread.md +275 -0
- package/docs/components/app-icon.md +36 -0
- package/docs/components/app-sidebar.md +92 -0
- package/docs/components/approval-card.md +71 -0
- package/docs/components/aurora.md +34 -0
- package/docs/components/avatar.md +37 -0
- package/docs/components/badge.md +36 -0
- package/docs/components/block-view.md +34 -0
- package/docs/components/breadcrumb.md +20 -0
- package/docs/components/button.md +23 -0
- package/docs/components/calendar.md +68 -0
- package/docs/components/card-view.md +73 -0
- package/docs/components/card.md +25 -0
- package/docs/components/chart.md +109 -0
- package/docs/components/check-button.md +16 -0
- package/docs/components/checklist.md +19 -0
- package/docs/components/code-editor.md +38 -0
- package/docs/components/composer.md +107 -0
- package/docs/components/context-menu.md +32 -0
- package/docs/components/copy.md +37 -0
- package/docs/components/data-filter.md +16 -0
- package/docs/components/date-picker.md +31 -0
- package/docs/components/date-range.md +21 -0
- package/docs/components/datebox.md +31 -0
- package/docs/components/dialog.md +25 -0
- package/docs/components/dock.md +57 -0
- package/docs/components/dropdown.md +39 -0
- package/docs/components/elements.md +63 -0
- package/docs/components/empty-state.md +17 -0
- package/docs/components/entity-ref.md +26 -0
- package/docs/components/field-upload.md +18 -0
- package/docs/components/file-item.md +27 -0
- package/docs/components/file-list.md +23 -0
- package/docs/components/filter-panel.md +45 -0
- package/docs/components/filter.md +47 -0
- package/docs/components/finder.md +25 -0
- package/docs/components/form-widgets.md +42 -0
- package/docs/components/form.md +80 -0
- package/docs/components/grid.md +26 -0
- package/docs/components/groupbox.md +11 -0
- package/docs/components/helpers.md +359 -0
- package/docs/components/icons.md +87 -0
- package/docs/components/index.md +99 -0
- package/docs/components/kanban-view.md +42 -0
- package/docs/components/kbd.md +23 -0
- package/docs/components/kernel.md +41 -0
- package/docs/components/launcher.md +66 -0
- package/docs/components/layout.md +33 -0
- package/docs/components/list-toolbar.md +38 -0
- package/docs/components/loading.md +48 -0
- package/docs/components/menu-button.md +47 -0
- package/docs/components/message.md +76 -0
- package/docs/components/modal.md +27 -0
- package/docs/components/module-bar.md +71 -0
- package/docs/components/multi-value-editor.md +16 -0
- package/docs/components/navigation-bar.md +22 -0
- package/docs/components/number-field.md +34 -0
- package/docs/components/pagination.md +73 -0
- package/docs/components/panel.md +28 -0
- package/docs/components/prompt-starters.md +40 -0
- package/docs/components/prose.md +38 -0
- package/docs/components/questionnaire.md +115 -0
- package/docs/components/rating.md +19 -0
- package/docs/components/run-status.md +50 -0
- package/docs/components/run-trace.md +72 -0
- package/docs/components/search.md +11 -0
- package/docs/components/select.md +129 -0
- package/docs/components/sheet-stack.md +39 -0
- package/docs/components/sheet.md +77 -0
- package/docs/components/skeleton.md +27 -0
- package/docs/components/slider.md +29 -0
- package/docs/components/sort-control.md +21 -0
- package/docs/components/source-list.md +30 -0
- package/docs/components/split-view.md +12 -0
- package/docs/components/stat-tile.md +49 -0
- package/docs/components/stepper.md +27 -0
- package/docs/components/surface.md +152 -0
- package/docs/components/tabbox.md +33 -0
- package/docs/components/table-view.md +43 -0
- package/docs/components/table.md +232 -0
- package/docs/components/tag-picker.md +39 -0
- package/docs/components/timebox.md +16 -0
- package/docs/components/toggle.md +21 -0
- package/docs/components/tokens.md +82 -0
- package/docs/components/toolbar.md +26 -0
- package/docs/components/tooltip.md +16 -0
- package/docs/components/tree.md +48 -0
- package/docs/components/truncate.md +21 -0
- package/docs/components/value-list.md +14 -0
- package/docs/components/view-settings.md +56 -0
- package/docs/components/workspace-switcher.md +42 -0
- package/docs/components/zeyos.md +196 -0
- package/docs/llms-small.txt +299 -0
- package/docs/llms.md +697 -100
- package/docs/llms.txt +46 -19
- package/package.json +9 -4
- package/src/components/activity-item/activity-item.js +21 -2
- package/src/components/agent-avatar/agent-avatar.css +195 -0
- package/src/components/agent-avatar/agent-avatar.js +333 -0
- package/src/components/agent-avatar/agent-face.js +292 -0
- package/src/components/agent-thread/ag-ui.js +44 -11
- package/src/components/agent-thread/agent-thread.js +103 -11
- package/src/components/agent-thread/ui-message-stream.js +3 -1
- package/src/components/app-rail/app-rail.css +5 -0
- package/src/components/app-sidebar/app-sidebar.css +3 -0
- package/src/components/app-sidebar/app-sidebar.js +4 -3
- package/src/components/approval-card/approval-card.css +6 -0
- package/src/components/approval-card/approval-card.js +55 -7
- package/src/components/aurora/aurora.css +149 -14
- package/src/components/aurora/aurora.js +49 -6
- package/src/components/calendar/calendar.css +6 -2
- package/src/components/calendar/calendar.js +127 -47
- package/src/components/card-view/card-view.js +5 -6
- package/src/components/chart/chart.css +159 -1
- package/src/components/chart/chart.js +450 -62
- package/src/components/chart/color.js +297 -0
- package/src/components/chart/svg-adapter.js +576 -0
- package/src/components/chart/svg-geometry.js +323 -0
- package/src/components/check-button/check-button.js +3 -18
- package/src/components/checklist/checklist.js +46 -17
- package/src/components/checklist/field-adapter.js +4 -1
- package/src/components/code-editor/code-editor.css +33 -0
- package/src/components/code-editor/code-editor.js +97 -8
- package/src/components/code-editor/field-adapter.js +3 -0
- package/src/components/composer/composer.css +3 -0
- package/src/components/composer/composer.js +100 -22
- package/src/components/context-menu/context-menu.js +41 -5
- package/src/components/copy/copy-button.js +9 -1
- package/src/components/copy/copy-input.js +5 -0
- package/src/components/data-filter/filter-core.js +0 -1
- package/src/components/date-picker/date-picker.css +8 -0
- package/src/components/date-picker/date-picker.js +47 -8
- package/src/components/date-picker/date-range-picker.js +1 -1
- package/src/components/date-picker/month-picker.js +19 -3
- package/src/components/date-picker/time-picker.js +54 -19
- package/src/components/datebox/date-range-box.js +7 -3
- package/src/components/datebox/datebox.js +32 -6
- package/src/components/dialog/dialog.css +6 -0
- package/src/components/dialog/dialog.js +22 -30
- package/src/components/dropdown/dropdown.js +1 -18
- package/src/components/empty-state/empty-state.js +21 -2
- package/src/components/field/field.js +19 -3
- package/src/components/fieldset/fieldset.js +3 -1
- package/src/components/filter/filter.js +9 -0
- package/src/components/form/form.js +19 -2
- package/src/components/kanban-view/kanban-card.js +15 -2
- package/src/components/kanban-view/kanban-view.css +21 -0
- package/src/components/kanban-view/kanban-view.js +29 -16
- package/src/components/launcher/launcher.css +14 -0
- package/src/components/launcher/launcher.js +54 -9
- package/src/components/master-panel/master-panel.js +24 -22
- package/src/components/menu-button/menu-button.js +26 -4
- package/src/components/message/message.css +228 -29
- package/src/components/message/message.js +664 -30
- package/src/components/modal/modal.js +70 -25
- package/src/components/modal/native-dialog.js +91 -0
- package/src/components/module-bar/module-bar.css +3 -0
- package/src/components/module-bar/module-bar.js +17 -4
- package/src/components/multi-value-editor/multi-value-editor.css +7 -2
- package/src/components/multi-value-editor/multi-value-editor.js +3 -2
- package/src/components/navigation-bar/navigation-bar.js +13 -1
- package/src/components/number-field/field-adapter.js +3 -0
- package/src/components/number-field/number-field.js +2 -1
- package/src/components/pagination/pagination.css +26 -2
- package/src/components/pagination/pagination.js +551 -65
- package/src/components/prose/prose.js +7 -1
- package/src/components/rating/field-adapter.js +3 -0
- package/src/components/run-status/run-status.js +43 -3
- package/src/components/run-trace/run-trace.js +15 -7
- package/src/components/search/search.js +3 -18
- package/src/components/select/field-adapter.js +8 -1
- package/src/components/select/select.js +68 -13
- package/src/components/sheet/sheet.js +27 -8
- package/src/components/slider/field-adapter.js +3 -0
- package/src/components/slider/slider.js +4 -6
- package/src/components/stat-tile/stat-tile.js +24 -9
- package/src/components/stepper/stepper.css +15 -0
- package/src/components/stepper/stepper.js +34 -2
- package/src/components/surface/catalog.js +185 -28
- package/src/components/surface/surface.js +10 -5
- package/src/components/tabbox/tabbox.js +13 -1
- package/src/components/table/table.css +160 -2
- package/src/components/table/table.js +479 -52
- package/src/components/table/window.js +46 -4
- package/src/components/table-view/table-view.js +1 -10
- package/src/components/tag-picker/field-adapter.js +3 -0
- package/src/components/tag-picker/tag-picker.js +2 -0
- package/src/components/timebox/field-adapter.js +3 -0
- package/src/components/toggle/toggle.js +51 -27
- package/src/components/tooltip/tooltip.js +21 -14
- package/src/components/tree/tree.js +87 -14
- package/src/components/truncate/truncate.js +21 -5
- package/src/components/value-list/value-list.js +37 -9
- package/src/components/view-settings/view-settings.js +1 -5
- package/src/core/component.js +34 -2
- package/src/core/date.js +5 -4
- package/src/core/drag-axis.js +24 -7
- package/src/core/export.js +4 -4
- package/src/core/fontawesome.js +34 -3
- package/src/core/format.js +3 -1
- package/src/core/http.js +23 -11
- package/src/core/icons.js +51 -10
- package/src/core/keyboard.js +83 -9
- package/src/core/messages.js +3 -0
- package/src/core/position.js +2 -2
- package/src/core/storage.js +80 -31
- package/src/core/util.js +16 -5
- package/src/elements/define.js +82 -47
- package/src/elements/kit.js +46 -35
- package/src/index.js +8 -4
- package/src/internal/agent-model.js +152 -0
- package/src/internal/app-rail.js +53 -2
- package/src/internal/collections.js +25 -0
- package/src/internal/menu-items.js +59 -0
- package/src/internal/overlay-content.js +35 -0
- package/src/internal/presence-loop.js +61 -14
- package/src/locales/de.js +3 -0
- package/src/zeyos/calendar.js +81 -19
- package/src/zeyos/connect.js +5 -1
- package/src/zeyos/form.js +29 -10
- package/src/zeyos/select.js +36 -12
- package/src/zeyos/table.js +43 -11
- package/src/zeyos/view.js +2 -1
- package/styles/tokens/semantic.css +7 -1
- package/styles/zx.css +1 -0
package/src/core/keyboard.js
CHANGED
|
@@ -6,7 +6,7 @@ const FOCUSABLE_SELECTOR = [
|
|
|
6
6
|
].join(',');
|
|
7
7
|
|
|
8
8
|
/** Attributes that change whether a roving item is available; nothing else is observed. */
|
|
9
|
-
const AVAILABILITY_ATTRIBUTES = ['hidden', 'disabled', 'aria-disabled', 'aria-hidden'];
|
|
9
|
+
const AVAILABILITY_ATTRIBUTES = ['hidden', 'inert', 'disabled', 'aria-disabled', 'aria-hidden'];
|
|
10
10
|
/** `<input>` types without a caret, which a roving group may move focus away from freely. */
|
|
11
11
|
const CARETLESS_INPUT_TYPES = new Set(['button', 'checkbox', 'color', 'file', 'image', 'reset', 'submit']);
|
|
12
12
|
|
|
@@ -54,6 +54,10 @@ export function focusTrap(container) {
|
|
|
54
54
|
/** @returns {void} */
|
|
55
55
|
function onKeydown(event) {
|
|
56
56
|
if (event.key !== 'Tab') return;
|
|
57
|
+
const active = document.activeElement;
|
|
58
|
+
// A modal dialog opened from inside the container but hosted elsewhere owns Tab: the container
|
|
59
|
+
// is inert behind it, so pulling focus back would leave the reader stranded.
|
|
60
|
+
if (inForeignModal(container, active)) return;
|
|
57
61
|
const items = focusableItems(container);
|
|
58
62
|
if (items.length === 0) {
|
|
59
63
|
event.preventDefault();
|
|
@@ -62,10 +66,13 @@ export function focusTrap(container) {
|
|
|
62
66
|
}
|
|
63
67
|
const first = items[0];
|
|
64
68
|
const last = items[items.length - 1];
|
|
65
|
-
|
|
69
|
+
const inside = active !== null && container.contains(active);
|
|
70
|
+
// Positions are compared in document order, so focus on the container itself, or on an element
|
|
71
|
+
// outside the tab order (`tabindex="-1"`) before the first or after the last stop, wraps too.
|
|
72
|
+
if (event.shiftKey && (!inside || active === first || precedes(active, first))) {
|
|
66
73
|
event.preventDefault();
|
|
67
74
|
last.focus();
|
|
68
|
-
} else if (!event.shiftKey && (
|
|
75
|
+
} else if (!event.shiftKey && (!inside || active === last || precedes(last, active))) {
|
|
69
76
|
event.preventDefault();
|
|
70
77
|
first.focus();
|
|
71
78
|
}
|
|
@@ -105,10 +112,14 @@ export function focusTrap(container) {
|
|
|
105
112
|
* the neighbouring item, so a reader is never trapped in it. Under `dir="rtl"` the horizontal
|
|
106
113
|
* arrows follow the visual order.
|
|
107
114
|
*
|
|
115
|
+
* An item is skipped while it is hidden, disabled, or `aria-hidden`, while an element between it
|
|
116
|
+
* and the container is `hidden` or `inert`, and — once the container is rendered — while it is not
|
|
117
|
+
* rendered itself. A group built detached or hidden still initializes from its attributes alone.
|
|
118
|
+
*
|
|
108
119
|
* The group re-reads its items when children are added or removed and when an availability
|
|
109
|
-
* attribute (`hidden`, `disabled`, `aria-disabled`, `aria-hidden`) changes on an item or
|
|
110
|
-
* element inside the container that holds items — a `<fieldset disabled>` toggled around
|
|
111
|
-
* own `tabindex` writes and unrelated attribute churn are not observed.
|
|
120
|
+
* attribute (`hidden`, `inert`, `disabled`, `aria-disabled`, `aria-hidden`) changes on an item or
|
|
121
|
+
* on an element inside the container that holds items — a `<fieldset disabled>` toggled around
|
|
122
|
+
* them; its own `tabindex` writes and unrelated attribute churn are not observed.
|
|
112
123
|
* @param {Element} container Event and query container.
|
|
113
124
|
* @param {string} itemSelector Selector for roving items.
|
|
114
125
|
* @param {RovingOptions} [options={}] Behavior options.
|
|
@@ -156,10 +167,11 @@ export function rovingTabindex(container, itemSelector, { orientation = 'vertica
|
|
|
156
167
|
const current = /** @type {HTMLElement[]} */ (Array.from(container.querySelectorAll(itemSelector)));
|
|
157
168
|
const present = new Set(current);
|
|
158
169
|
for (const item of originals.keys()) if (!present.has(item)) release(item);
|
|
170
|
+
const rendered = isRendered(container);
|
|
159
171
|
return current
|
|
160
172
|
.filter((item) => {
|
|
161
173
|
remember(item);
|
|
162
|
-
return
|
|
174
|
+
return isRovingAvailable(item, container, rendered);
|
|
163
175
|
});
|
|
164
176
|
}
|
|
165
177
|
|
|
@@ -182,6 +194,15 @@ export function rovingTabindex(container, itemSelector, { orientation = 'vertica
|
|
|
182
194
|
if (item.tabIndex !== tabindex) item.tabIndex = tabindex;
|
|
183
195
|
managed.set(item, item.getAttribute('tabindex'));
|
|
184
196
|
}
|
|
197
|
+
// An item out of reach only for now — in a hidden or undisplayed holder — is parked out of the
|
|
198
|
+
// Tab order, so revealing its holder by a class or style change, which nothing observes, cannot
|
|
199
|
+
// add a second tab stop to the group.
|
|
200
|
+
const reachable = new Set(available);
|
|
201
|
+
for (const item of originals.keys()) {
|
|
202
|
+
if (reachable.has(item) || !isAvailable(item) || !container.contains(item)) continue;
|
|
203
|
+
if (item.tabIndex !== -1) item.tabIndex = -1;
|
|
204
|
+
managed.set(item, item.getAttribute('tabindex'));
|
|
205
|
+
}
|
|
185
206
|
}
|
|
186
207
|
|
|
187
208
|
/** @param {KeyboardEvent} event @returns {void} */
|
|
@@ -478,10 +499,63 @@ function isRightToLeft(container, rtl) {
|
|
|
478
499
|
}
|
|
479
500
|
}
|
|
480
501
|
|
|
481
|
-
/**
|
|
502
|
+
/**
|
|
503
|
+
* The Tab stops inside a container, in document order. A control taken out of the tab order with a
|
|
504
|
+
* negative `tabindex` — every item but one of a roving toolbar or tab list — is no stop, and so can
|
|
505
|
+
* never be the first or last one a focus trap wraps around.
|
|
506
|
+
* @param {Element} container @returns {HTMLElement[]}
|
|
507
|
+
*/
|
|
482
508
|
function focusableItems(container) {
|
|
483
509
|
return /** @type {HTMLElement[]} */ (Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR)))
|
|
484
|
-
.filter((item) => isAvailable(item) && item.
|
|
510
|
+
.filter((item) => isAvailable(item) && !(Number.parseInt(item.getAttribute('tabindex') ?? '', 10) < 0)
|
|
511
|
+
&& !item.closest('[inert]') && item.getClientRects().length > 0);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Whether `a` comes before `b` in document order; an ancestor comes before its descendants.
|
|
516
|
+
* @param {Node} a @param {Node} b @returns {boolean}
|
|
517
|
+
*/
|
|
518
|
+
function precedes(a, b) {
|
|
519
|
+
return a !== b && Boolean(b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Whether focus sits in a modal dialog the container is not part of.
|
|
524
|
+
* @param {Element} container Trap container.
|
|
525
|
+
* @param {Element|null} active Focused element.
|
|
526
|
+
* @returns {boolean}
|
|
527
|
+
*/
|
|
528
|
+
function inForeignModal(container, active) {
|
|
529
|
+
if (!active || typeof active.closest !== 'function' || container.contains(active)) return false;
|
|
530
|
+
let dialog;
|
|
531
|
+
try {
|
|
532
|
+
dialog = active.closest('dialog:modal');
|
|
533
|
+
} catch {
|
|
534
|
+
// Without `:modal`, an open dialog is known by its attribute.
|
|
535
|
+
dialog = active.closest('dialog[open]');
|
|
536
|
+
}
|
|
537
|
+
return dialog !== null && !dialog.contains(container);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Whether a roving item can take focus now.
|
|
542
|
+
* @param {HTMLElement} item Candidate item.
|
|
543
|
+
* @param {Element} container Group container.
|
|
544
|
+
* @param {boolean} rendered Whether the container is rendered, so the item's own rendering counts.
|
|
545
|
+
* @returns {boolean}
|
|
546
|
+
*/
|
|
547
|
+
function isRovingAvailable(item, container, rendered) {
|
|
548
|
+
if (!isAvailable(item)) return false;
|
|
549
|
+
// Only holders inside the group count: a hidden or inert group as a whole still initializes.
|
|
550
|
+
const holder = item.closest('[hidden], [inert]');
|
|
551
|
+
if (holder && holder !== container && container.contains(holder)) return false;
|
|
552
|
+
return !rendered || item.getClientRects().length > 0;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/** @param {Element} container @returns {boolean} Whether the container is connected and laid out. */
|
|
556
|
+
function isRendered(container) {
|
|
557
|
+
return container.isConnected && typeof container.getClientRects === 'function'
|
|
558
|
+
&& container.getClientRects().length > 0;
|
|
485
559
|
}
|
|
486
560
|
|
|
487
561
|
/** @param {Element} item @returns {item is HTMLElement} */
|
package/src/core/messages.js
CHANGED
|
@@ -581,6 +581,9 @@ export const defaultMessages = Object.freeze({
|
|
|
581
581
|
|
|
582
582
|
'numberField.empty': 'Empty',
|
|
583
583
|
|
|
584
|
+
'pagination.auto': 'Auto',
|
|
585
|
+
'pagination.autoLoad': 'Auto-load',
|
|
586
|
+
'pagination.autoSize': 'Auto (%1)',
|
|
584
587
|
'pagination.empty': '0 of 0',
|
|
585
588
|
'pagination.label': 'Pagination',
|
|
586
589
|
'pagination.loaded': '%1 of %2',
|
package/src/core/position.js
CHANGED
|
@@ -37,7 +37,6 @@ export function position(anchor, floating, options = {}) {
|
|
|
37
37
|
const offset = Number(options.offset ?? 4);
|
|
38
38
|
const flip = options.flip ?? true;
|
|
39
39
|
const matchWidth = options.matchWidth ?? false;
|
|
40
|
-
const anchorStyle = anchor.getAttribute('style');
|
|
41
40
|
const floatingStyle = floating.getAttribute('style');
|
|
42
41
|
const popover = floating.getAttribute('popover');
|
|
43
42
|
let destroyed = false;
|
|
@@ -113,7 +112,8 @@ export function position(anchor, floating, options = {}) {
|
|
|
113
112
|
const rest = anchorNames(anchor).filter((name) => name !== anchorName);
|
|
114
113
|
if (rest.length) /** @type {HTMLElement} */ (anchor).style.setProperty('anchor-name', rest.join(', '));
|
|
115
114
|
else /** @type {HTMLElement} */ (anchor).style.removeProperty('anchor-name');
|
|
116
|
-
|
|
115
|
+
// Whichever controller leaves last, an attribute emptied by our names goes with them.
|
|
116
|
+
if (anchor.getAttribute('style') === '') anchor.removeAttribute('style');
|
|
117
117
|
}
|
|
118
118
|
restoreInlineStyle(floating, floatingStyle);
|
|
119
119
|
restoreAttribute(floating, 'popover', popover);
|
package/src/core/storage.js
CHANGED
|
@@ -18,18 +18,31 @@
|
|
|
18
18
|
const PREFIX = 'zx2:';
|
|
19
19
|
/** The previous format cannot distinguish namespace separators from key separators. */
|
|
20
20
|
const LEGACY_PREFIX = 'zx:';
|
|
21
|
-
/**
|
|
21
|
+
/** Read once to detect an area that exists but refuses access altogether. */
|
|
22
22
|
const PROBE_KEY = 'zx:__probe__';
|
|
23
23
|
|
|
24
|
+
/*
|
|
25
|
+
* The in-memory fallbacks, one per storage area, shared by every view of that area: a value a view
|
|
26
|
+
* could not persist is still there for the next `storage()` call with the same namespace — a
|
|
27
|
+
* component re-created on the same page reads back what its predecessor wrote. Module state is
|
|
28
|
+
* deliberate here; the "no module-level mutable state" rule is for components. An area that exists
|
|
29
|
+
* is keyed by its Storage object, so a replaced area starts with a clean fallback.
|
|
30
|
+
*/
|
|
31
|
+
/** @type {WeakMap<Storage, {memory: Map<string, string>, known: Map<string, string>}>} */
|
|
32
|
+
const AREA_FALLBACKS = new WeakMap();
|
|
33
|
+
/** @type {Map<string, {memory: Map<string, string>, known: Map<string, string>}>} */
|
|
34
|
+
const MISSING_AREA_FALLBACKS = new Map();
|
|
35
|
+
|
|
24
36
|
/**
|
|
25
37
|
* Creates a namespaced, JSON-encoded view of `localStorage` or `sessionStorage`.
|
|
26
38
|
*
|
|
27
39
|
* Keys use `zx2:<namespace length>:<namespace>:<key>`, so namespaces cannot overlap. Existing
|
|
28
40
|
* `zx:` keys are copied only when explicitly requested through `migrateLegacy(keys)`; they are
|
|
29
41
|
* never deleted. `clear()` only touches the current namespace. When the storage area is
|
|
30
|
-
* unavailable or refuses a write — private browsing, a full quota, cookies disabled — the
|
|
31
|
-
*
|
|
32
|
-
* need a try/catch and never see an exception.
|
|
42
|
+
* unavailable or refuses a write — private browsing, a full quota, cookies disabled — the value
|
|
43
|
+
* goes to an in-memory map that lives as long as the page and is shared by every view of the same
|
|
44
|
+
* area, so callers never need a try/catch and never see an exception. A refused write affects only
|
|
45
|
+
* that value: everything else is still read from, and written to, the real storage area.
|
|
33
46
|
*
|
|
34
47
|
* @param {string} namespace Namespace segment, typically an application or feature name.
|
|
35
48
|
* @param {StorageOptions} [options={}] Area selection.
|
|
@@ -41,48 +54,44 @@ export function storage(namespace, options = {}) {
|
|
|
41
54
|
const prefix = `${PREFIX}${name.length}:${name}:`;
|
|
42
55
|
const legacyPrefix = `${LEGACY_PREFIX}${name}:`;
|
|
43
56
|
const migratedPrefix = `zx2m:${name.length}:${name}:`;
|
|
44
|
-
/** @type {Map<string, string>} */
|
|
45
|
-
const memory = new Map();
|
|
46
57
|
let backing = resolveArea(area);
|
|
58
|
+
const memory = fallbackFor(area, backing);
|
|
59
|
+
// What views of this area last read from or wrote to it, so values seen survive an area that
|
|
60
|
+
// stops answering later in the session (access revoked, storage disabled).
|
|
61
|
+
const known = knownFor(area, backing);
|
|
47
62
|
|
|
48
63
|
/** @param {string} key @returns {string|null} */
|
|
49
64
|
const readRaw = (key) => {
|
|
65
|
+
// A value held in memory is one the area refused: it is newer than whatever the area kept.
|
|
66
|
+
if (memory.has(key)) return /** @type {string} */ (memory.get(key));
|
|
50
67
|
if (backing !== null) {
|
|
51
68
|
try {
|
|
52
69
|
const raw = backing.getItem(key);
|
|
53
|
-
if (raw === null)
|
|
54
|
-
else
|
|
70
|
+
if (raw === null) known.delete(key);
|
|
71
|
+
else known.set(key, raw);
|
|
55
72
|
return raw;
|
|
56
73
|
} catch {
|
|
57
74
|
backing = null;
|
|
58
75
|
}
|
|
59
76
|
}
|
|
60
|
-
return
|
|
77
|
+
return known.has(key) ? /** @type {string} */ (known.get(key)) : null;
|
|
61
78
|
};
|
|
62
79
|
|
|
63
80
|
/** @param {string} key @param {string} raw @returns {void} */
|
|
64
81
|
const writeRaw = (key, raw) => {
|
|
65
|
-
// Retain successful writes as well: a later quota failure must not hide this view's data.
|
|
66
|
-
memory.set(key, raw);
|
|
67
82
|
if (backing !== null) {
|
|
68
83
|
try {
|
|
69
84
|
backing.setItem(key, raw);
|
|
85
|
+
// Persisted, so an older refused value must not shadow it any longer.
|
|
86
|
+
memory.delete(key);
|
|
87
|
+
known.set(key, raw);
|
|
70
88
|
return;
|
|
71
89
|
} catch {
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
for (const cached of memory.keys()) {
|
|
75
|
-
if (cached === key) continue;
|
|
76
|
-
try {
|
|
77
|
-
const current = backing.getItem(cached);
|
|
78
|
-
if (current === null) memory.delete(cached);
|
|
79
|
-
else memory.set(cached, current);
|
|
80
|
-
} catch { break; }
|
|
81
|
-
}
|
|
82
|
-
// A quota error mid-session degrades this view to memory rather than throwing.
|
|
83
|
-
backing = null;
|
|
90
|
+
// A full quota refuses this write only. The area stays in use for reads and later writes;
|
|
91
|
+
// the refused value is kept in memory as the caller's intended value.
|
|
84
92
|
}
|
|
85
93
|
}
|
|
94
|
+
memory.set(key, raw);
|
|
86
95
|
};
|
|
87
96
|
|
|
88
97
|
/** @param {string} key @returns {void} */
|
|
@@ -95,23 +104,25 @@ export function storage(namespace, options = {}) {
|
|
|
95
104
|
}
|
|
96
105
|
}
|
|
97
106
|
memory.delete(key);
|
|
107
|
+
known.delete(key);
|
|
98
108
|
};
|
|
99
109
|
|
|
100
110
|
/** @returns {string[]} */
|
|
101
111
|
const rawKeys = () => {
|
|
112
|
+
const found = new Set();
|
|
102
113
|
if (backing !== null) {
|
|
103
114
|
try {
|
|
104
|
-
const found = [];
|
|
105
115
|
for (let index = 0; index < backing.length; index += 1) {
|
|
106
116
|
const key = backing.key(index);
|
|
107
|
-
if (typeof key === 'string' && key.startsWith(prefix)) found.
|
|
117
|
+
if (typeof key === 'string' && key.startsWith(prefix)) found.add(key);
|
|
108
118
|
}
|
|
109
|
-
return found;
|
|
110
119
|
} catch {
|
|
111
120
|
backing = null;
|
|
112
121
|
}
|
|
113
122
|
}
|
|
114
|
-
|
|
123
|
+
if (backing === null) for (const key of known.keys()) if (key.startsWith(prefix)) found.add(key);
|
|
124
|
+
for (const key of memory.keys()) if (key.startsWith(prefix)) found.add(key);
|
|
125
|
+
return [...found];
|
|
115
126
|
};
|
|
116
127
|
|
|
117
128
|
return {
|
|
@@ -209,7 +220,10 @@ export function storage(namespace, options = {}) {
|
|
|
209
220
|
}
|
|
210
221
|
|
|
211
222
|
/**
|
|
212
|
-
* Returns a
|
|
223
|
+
* Returns a readable Web Storage area, or null when it is missing or refuses access.
|
|
224
|
+
*
|
|
225
|
+
* An area that reads but refuses writes — Safari's private mode, a quota already full — is still
|
|
226
|
+
* returned: what it holds stays readable, and each refused write falls back on its own.
|
|
213
227
|
* @param {'local'|'session'} area Area name.
|
|
214
228
|
* @returns {Storage|null}
|
|
215
229
|
*/
|
|
@@ -218,11 +232,46 @@ function resolveArea(area) {
|
|
|
218
232
|
try {
|
|
219
233
|
const candidate = globalThis[name];
|
|
220
234
|
if (!candidate || typeof candidate.getItem !== 'function') return null;
|
|
221
|
-
|
|
222
|
-
candidate.setItem(PROBE_KEY, '1');
|
|
223
|
-
candidate.removeItem(PROBE_KEY);
|
|
235
|
+
candidate.getItem(PROBE_KEY);
|
|
224
236
|
return candidate;
|
|
225
237
|
} catch {
|
|
226
238
|
return null;
|
|
227
239
|
}
|
|
228
240
|
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* The shared in-memory fallback for an area.
|
|
244
|
+
* @param {'local'|'session'} area Area name.
|
|
245
|
+
* @param {Storage|null} backing The resolved area, or null when there is none.
|
|
246
|
+
* @returns {Map<string, string>}
|
|
247
|
+
*/
|
|
248
|
+
function fallbackFor(area, backing) {
|
|
249
|
+
return fallbackEntry(area, backing).memory;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* The values views of an area last read from or wrote to it, shared like the fallback so a value
|
|
254
|
+
* removed through one view does not come back through another once the area stops answering.
|
|
255
|
+
* @param {'local'|'session'} area
|
|
256
|
+
* @param {Storage|null} backing
|
|
257
|
+
* @returns {Map<string, string>}
|
|
258
|
+
*/
|
|
259
|
+
function knownFor(area, backing) {
|
|
260
|
+
return fallbackEntry(area, backing).known;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* @param {'local'|'session'} area
|
|
265
|
+
* @param {Storage|null} backing
|
|
266
|
+
* @returns {{memory: Map<string, string>, known: Map<string, string>}}
|
|
267
|
+
*/
|
|
268
|
+
function fallbackEntry(area, backing) {
|
|
269
|
+
const table = backing === null ? MISSING_AREA_FALLBACKS : AREA_FALLBACKS;
|
|
270
|
+
const key = backing ?? (area === 'session' ? 'session' : 'local');
|
|
271
|
+
let entry = table.get(/** @type {any} */ (key));
|
|
272
|
+
if (!entry) {
|
|
273
|
+
entry = { memory: new Map(), known: new Map() };
|
|
274
|
+
table.set(/** @type {any} */ (key), entry);
|
|
275
|
+
}
|
|
276
|
+
return entry;
|
|
277
|
+
}
|
package/src/core/util.js
CHANGED
|
@@ -91,7 +91,9 @@ export function uid(prefix = 'zx') {
|
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* Recursively merges plain objects without mutating either input.
|
|
94
|
-
* Arrays and other values are replaced rather than merged.
|
|
94
|
+
* Arrays and other values are replaced rather than merged. Only own enumerable keys are copied,
|
|
95
|
+
* each as an own data property, so a `__proto__` key from parsed JSON stays an ordinary key and
|
|
96
|
+
* never changes the result's prototype.
|
|
95
97
|
* @template T
|
|
96
98
|
* @template U
|
|
97
99
|
* @param {T} a Base value.
|
|
@@ -103,10 +105,11 @@ export function deepMerge(a, b) {
|
|
|
103
105
|
if (!isPlainObject(b)) return /** @type {T & U} */ (cloneValue(b));
|
|
104
106
|
|
|
105
107
|
for (const [key, value] of Object.entries(b)) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
const current = Object.hasOwn(result, key) ? result[key] : undefined;
|
|
109
|
+
if (isPlainObject(value) && isPlainObject(current)) {
|
|
110
|
+
defineOwn(result, key, deepMerge(current, value));
|
|
108
111
|
} else {
|
|
109
|
-
result
|
|
112
|
+
defineOwn(result, key, cloneValue(value));
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
115
|
return /** @type {T & U} */ (result);
|
|
@@ -344,10 +347,18 @@ function isPlainObject(value) {
|
|
|
344
347
|
/** @param {Record<string, any>} value @returns {Record<string, any>} */
|
|
345
348
|
function clonePlainObject(value) {
|
|
346
349
|
const result = {};
|
|
347
|
-
for (const [key, item] of Object.entries(value)) result
|
|
350
|
+
for (const [key, item] of Object.entries(value)) defineOwn(result, key, cloneValue(item));
|
|
348
351
|
return result;
|
|
349
352
|
}
|
|
350
353
|
|
|
354
|
+
/**
|
|
355
|
+
* Sets an own, enumerable data property. Plain assignment would run the `__proto__` setter.
|
|
356
|
+
* @param {Record<string, any>} target @param {string} key @param {unknown} value @returns {void}
|
|
357
|
+
*/
|
|
358
|
+
function defineOwn(target, key, value) {
|
|
359
|
+
Object.defineProperty(target, key, { value, enumerable: true, writable: true, configurable: true });
|
|
360
|
+
}
|
|
361
|
+
|
|
351
362
|
/** @param {any} value @returns {any} */
|
|
352
363
|
function cloneValue(value) {
|
|
353
364
|
if (isPlainObject(value)) return clonePlainObject(value);
|