@zeyos/zx 5.7.0 → 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 +330 -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 +48 -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 +15 -4
- 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 +45 -8
- 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 +31 -1
- 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 +20 -6
- 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/dom.d.ts +14 -0
- 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 +3161 -515
- 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 +970 -57
- package/dist/zx.esm.js +6405 -2249
- package/dist/zx.esm.min.js +26 -26
- package/dist/zx.global.js +6405 -2249
- package/dist/zx.global.min.js +26 -26
- package/dist/zx.layered.css +972 -57
- 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 +3154 -518
- 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 +725 -109
- 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/button/button.css +24 -11
- 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.css +9 -1
- package/src/components/checklist/checklist.js +105 -20
- package/src/components/checklist/field-adapter.js +6 -12
- 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 +24 -33
- 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 +129 -30
- 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 +70 -16
- 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 +39 -13
- 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/dom.js +45 -2
- 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 +60 -8
- package/src/core/keyboard.js +83 -9
- package/src/core/messages.js +3 -0
- package/src/core/position.js +4 -3
- 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
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Component } from '../../core/component.js';
|
|
2
2
|
import { h } from '../../core/dom.js';
|
|
3
3
|
import { connectedOverlayHost, overlayScope } from '../../core/overlay-host.js';
|
|
4
|
-
import { pushOverlay } from '../../core/overlay-stack.js';
|
|
4
|
+
import { overlayStack, pushOverlay } from '../../core/overlay-stack.js';
|
|
5
|
+
import { replaceContent } from '../../internal/overlay-content.js';
|
|
6
|
+
import { closeDialog, isDialogOpen, matchesState, showDialogModal } from './native-dialog.js';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Controls initial focus may be placed on: what a reader reaches with Tab, rather than everything
|
|
@@ -17,13 +19,21 @@ const FOCUSABLE_SELECTOR = [
|
|
|
17
19
|
* @property {Node|string|number|{toElement: () => Node|null}|null} [content=null] Modal content.
|
|
18
20
|
* @property {string|number} [width='auto'] CSS width, or a pixel width when numeric.
|
|
19
21
|
* @property {boolean} [closable=true] Whether Escape may close the modal.
|
|
20
|
-
* @property {boolean} [lightDismiss=false] Whether a backdrop click closes the modal.
|
|
22
|
+
* @property {boolean} [lightDismiss=false] Whether a backdrop click closes the modal. Like every
|
|
23
|
+
* dismissal by the reader, it raises a preventable `cancel` first.
|
|
21
24
|
* @property {boolean} [destroyOnClose=false] Whether to destroy the modal after it closes.
|
|
22
25
|
* @property {Element|string|null} [scope=null] Element whose nearest Zx theme scope owns the overlay; defaults to the opener. Resolved on every open, so a scope connected after construction still owns it.
|
|
23
26
|
* @property {(event: CustomEvent<Record<string, never>>) => void} [onopen] Open event listener.
|
|
24
27
|
* @property {(event: CustomEvent<{result: unknown}>) => void} [onclose] Close event listener.
|
|
25
|
-
* @property {(event: CustomEvent<
|
|
28
|
+
* @property {(event: CustomEvent<ModalCancelDetail>) => void} [oncancel] Cancel event listener.
|
|
26
29
|
*/
|
|
30
|
+
/**
|
|
31
|
+
* What the reader did to ask for dismissal: pressed Escape, used a header close button, chose a
|
|
32
|
+
* footer button whose action is `'cancel'`, clicked the backdrop, pressed outside a non-modal
|
|
33
|
+
* overlay, or dragged it away.
|
|
34
|
+
* @typedef {'escape'|'close-button'|'button'|'backdrop'|'outside'|'drag'} ModalDismissReason
|
|
35
|
+
*/
|
|
36
|
+
/** @typedef {{reason: ModalDismissReason}} ModalCancelDetail */
|
|
27
37
|
|
|
28
38
|
/**
|
|
29
39
|
* Thin native-dialog overlay with lifecycle-safe content and dismissal behavior.
|
|
@@ -65,6 +75,12 @@ export class Modal extends Component {
|
|
|
65
75
|
#opener = null;
|
|
66
76
|
/** @type {import('../../core/overlay-stack.js').OverlayHandle|null} Entry on the overlay stack while shown. */
|
|
67
77
|
#overlay = null;
|
|
78
|
+
/** Whether the `open` attribute stands in for a `showModal()` the platform does not have. */
|
|
79
|
+
#attributeModal = false;
|
|
80
|
+
/** Whether the press the next `click` completes began on the backdrop. */
|
|
81
|
+
#backdropPress = false;
|
|
82
|
+
/** Set once `destroy()` has finished; a close queued before it then settles nothing. */
|
|
83
|
+
#destroyed = false;
|
|
68
84
|
|
|
69
85
|
/**
|
|
70
86
|
* Creates a modal in the configured theme scope, or at document level when none is present.
|
|
@@ -76,16 +92,54 @@ export class Modal extends Component {
|
|
|
76
92
|
this.#setWidth(this.options.width);
|
|
77
93
|
replaceContent(this.refs.content, this.options.content);
|
|
78
94
|
|
|
95
|
+
/*
|
|
96
|
+
* Escape on a modal presentation is answered here rather than by the browser's close request.
|
|
97
|
+
* A browser stops honouring a prevented `cancel` once close requests repeat without other
|
|
98
|
+
* interaction, which would let a third Escape through an "unsaved changes" guard; a cancelled
|
|
99
|
+
* keydown never becomes a close request at all. The listener sits on `window`, the last stop
|
|
100
|
+
* of the bubble, so everything that may use the key first has had it: a popup inside the
|
|
101
|
+
* dialog, the overlay stack, an application's own `document` handler. Whatever they prevented
|
|
102
|
+
* is not ours. Only the topmost modal answers, so a dialog opened above this one — the
|
|
103
|
+
* library's or the application's — keeps its key.
|
|
104
|
+
*/
|
|
105
|
+
if (typeof window !== 'undefined') this.listen(window, 'keydown', (event) => {
|
|
106
|
+
const key = /** @type {KeyboardEvent} */ (event);
|
|
107
|
+
if (key.key !== 'Escape' || key.defaultPrevented || key.isComposing) return;
|
|
108
|
+
if (!this.isOpen() || !this._isModal()) return;
|
|
109
|
+
const topmost = topmostModalFor(key);
|
|
110
|
+
if (topmost && topmost !== this.el) return;
|
|
111
|
+
// Reported before the key is cancelled: a `cancel` listener may ask whether something else
|
|
112
|
+
// had already claimed this keydown, and our own claim must not answer for it.
|
|
113
|
+
if (this.options.closable) this._requestDismiss('escape');
|
|
114
|
+
else this.emit('cancel', { reason: 'escape' });
|
|
115
|
+
key.preventDefault();
|
|
116
|
+
});
|
|
117
|
+
/*
|
|
118
|
+
* The platform's own close request, for what is not a keydown this class saw: a back gesture,
|
|
119
|
+
* an Escape pressed mid-composition, an assistive-technology dismiss. The browser may make
|
|
120
|
+
* such a request non-cancelable, and then the dialog closes whatever a listener says.
|
|
121
|
+
*/
|
|
79
122
|
this.listen(this.el, 'cancel', (event) => {
|
|
80
|
-
const cancelEvent = this.emit('cancel');
|
|
123
|
+
const cancelEvent = this.emit('cancel', { reason: 'escape' });
|
|
81
124
|
if (!this.options.closable || cancelEvent.defaultPrevented) event.preventDefault();
|
|
82
125
|
});
|
|
83
126
|
this.listen(this.el, 'close', () => {
|
|
84
127
|
this._settleClose(this.#nativeClosingPresentations.shift());
|
|
85
128
|
});
|
|
129
|
+
/*
|
|
130
|
+
* A backdrop click is a press that starts and ends on the backdrop. The `click` alone cannot
|
|
131
|
+
* tell: a press inside the panel — selecting text in a field — dragged out and released over
|
|
132
|
+
* the backdrop dispatches its `click` on the dialog, outside the panel's box.
|
|
133
|
+
*/
|
|
134
|
+
this.listen(this.el, 'pointerdown', (event) => {
|
|
135
|
+
this.#backdropPress = event.target === this.el && isBackdropClick(this.el, /** @type {MouseEvent} */ (event));
|
|
136
|
+
});
|
|
86
137
|
this.listen(this.el, 'click', (event) => {
|
|
87
|
-
|
|
88
|
-
this
|
|
138
|
+
const pressed = this.#backdropPress;
|
|
139
|
+
this.#backdropPress = false;
|
|
140
|
+
if (!this.options.lightDismiss || !pressed || event.target !== this.el
|
|
141
|
+
|| !isBackdropClick(this.el, /** @type {MouseEvent} */ (event))) return;
|
|
142
|
+
this._requestDismiss('backdrop');
|
|
89
143
|
});
|
|
90
144
|
/*
|
|
91
145
|
* One listener for every close path, because `close` is the one event all four converge on:
|
|
@@ -113,10 +167,24 @@ export class Modal extends Component {
|
|
|
113
167
|
|
|
114
168
|
/**
|
|
115
169
|
* Puts the dialog on screen. Overridden by subclasses that open non-modally.
|
|
170
|
+
*
|
|
171
|
+
* Where the platform has no `showModal()` — a DOM implementation used for unit tests — the dialog
|
|
172
|
+
* is presented through its `open` attribute instead: no top layer and no inertness, but `open()`,
|
|
173
|
+
* `close()`, Escape and the lifecycle events behave the same.
|
|
116
174
|
* @returns {void}
|
|
117
175
|
*/
|
|
118
176
|
_show() {
|
|
119
|
-
this.el
|
|
177
|
+
this.#attributeModal = !showDialogModal(this.el);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Whether the current presentation is the modal one: the platform's `:modal`, or the `open`
|
|
182
|
+
* attribute standing in for `showModal()` where that is missing.
|
|
183
|
+
* @returns {boolean}
|
|
184
|
+
* @protected
|
|
185
|
+
*/
|
|
186
|
+
_isModal() {
|
|
187
|
+
return matchesState(this.el, ':modal') || (this.#attributeModal && isDialogOpen(this.el));
|
|
120
188
|
}
|
|
121
189
|
|
|
122
190
|
/**
|
|
@@ -129,7 +197,7 @@ export class Modal extends Component {
|
|
|
129
197
|
_hide(result = '', presentation = this.#presentation) {
|
|
130
198
|
this.#nativeClosingPresentations.push(presentation);
|
|
131
199
|
try {
|
|
132
|
-
this.el
|
|
200
|
+
closeDialog(this.el, result);
|
|
133
201
|
} catch (error) {
|
|
134
202
|
this.#nativeClosingPresentations.pop();
|
|
135
203
|
throw error;
|
|
@@ -143,6 +211,7 @@ export class Modal extends Component {
|
|
|
143
211
|
* @returns {void}
|
|
144
212
|
*/
|
|
145
213
|
_present() {
|
|
214
|
+
this.#attributeModal = false;
|
|
146
215
|
this._show();
|
|
147
216
|
this.#presentation += 1;
|
|
148
217
|
this.#syncModality();
|
|
@@ -160,7 +229,7 @@ export class Modal extends Component {
|
|
|
160
229
|
* @returns {void}
|
|
161
230
|
*/
|
|
162
231
|
#syncModality() {
|
|
163
|
-
if (this.el
|
|
232
|
+
if (matchesState(this.el, ':modal')) this.el.setAttribute('aria-modal', 'true');
|
|
164
233
|
else if (this.el.getAttribute('aria-modal') === 'true') this.el.removeAttribute('aria-modal');
|
|
165
234
|
}
|
|
166
235
|
|
|
@@ -168,20 +237,37 @@ export class Modal extends Component {
|
|
|
168
237
|
* Describes the current presentation for the overlay stack, or returns null to stay off it.
|
|
169
238
|
*
|
|
170
239
|
* The kind is read from the platform like `aria-modal` is: a `showModal()` dialog is `modal`,
|
|
171
|
-
* and
|
|
172
|
-
* presenting that way adds the Escape and outside-press
|
|
240
|
+
* and the stack leaves its Escape alone (this class answers it, see the constructor); anything
|
|
241
|
+
* else is `non-modal`, and a subclass presenting that way adds the Escape and outside-press
|
|
242
|
+
* handling it wants.
|
|
173
243
|
* @returns {import('../../core/overlay-stack.js').OverlayEntryOptions|null}
|
|
174
244
|
* @protected
|
|
175
245
|
*/
|
|
176
246
|
_overlayEntry() {
|
|
177
247
|
return {
|
|
178
|
-
kind: this.
|
|
248
|
+
kind: this._isModal() ? 'modal' : 'non-modal',
|
|
179
249
|
root: this.el,
|
|
180
250
|
owner: this,
|
|
181
251
|
anchor: this.#opener
|
|
182
252
|
};
|
|
183
253
|
}
|
|
184
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Asks to close on the reader's behalf: emits a preventable `cancel` naming what they did, and
|
|
257
|
+
* closes unless a listener prevented it. Every dismissal gesture goes through here; `close()`
|
|
258
|
+
* itself stays unconditional, for the application's own decisions.
|
|
259
|
+
* @param {ModalDismissReason} reason What the reader did.
|
|
260
|
+
* @returns {boolean} Whether the overlay is closing.
|
|
261
|
+
* @fires Modal#cancel
|
|
262
|
+
* @protected
|
|
263
|
+
*/
|
|
264
|
+
_requestDismiss(reason) {
|
|
265
|
+
if (!this.isOpen()) return false;
|
|
266
|
+
if (this.emit('cancel', { reason }).defaultPrevented) return false;
|
|
267
|
+
this.close();
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
|
|
185
271
|
/**
|
|
186
272
|
* Re-registers the current presentation on the overlay stack: called after every presentation,
|
|
187
273
|
* including a subclass's change of address that bypasses `open()`.
|
|
@@ -233,7 +319,7 @@ export class Modal extends Component {
|
|
|
233
319
|
* @returns {boolean}
|
|
234
320
|
*/
|
|
235
321
|
_isShown() {
|
|
236
|
-
return this.el
|
|
322
|
+
return isDialogOpen(this.el);
|
|
237
323
|
}
|
|
238
324
|
|
|
239
325
|
/**
|
|
@@ -257,7 +343,7 @@ export class Modal extends Component {
|
|
|
257
343
|
* @returns {boolean} Whether this event closed the current presentation.
|
|
258
344
|
*/
|
|
259
345
|
_settleClose(closingPresentation) {
|
|
260
|
-
if (!this._isRealClose(closingPresentation)) {
|
|
346
|
+
if (this.#destroyed || !this._isRealClose(closingPresentation)) {
|
|
261
347
|
if (closingPresentation !== undefined) this.#pendingResults.delete(closingPresentation);
|
|
262
348
|
return false;
|
|
263
349
|
}
|
|
@@ -421,9 +507,19 @@ export class Modal extends Component {
|
|
|
421
507
|
if (this.#destroying) return;
|
|
422
508
|
this.#destroying = true;
|
|
423
509
|
if (this.isOpen()) this._dismiss();
|
|
424
|
-
|
|
510
|
+
/*
|
|
511
|
+
* A close under way — started just now, or by a `close()` called just before — settles from a
|
|
512
|
+
* queued event that never arrives once listeners are aborted, so it is settled here: `close` is
|
|
513
|
+
* emitted once with that close's result, as on every other close path, and focus goes back to
|
|
514
|
+
* the opener while that listener is still attached.
|
|
515
|
+
*/
|
|
516
|
+
if (this.el.dataset.state === 'open') {
|
|
517
|
+
this.#nativeClosingPresentations.length = 0;
|
|
518
|
+
this._settleClose(this.#presentation);
|
|
519
|
+
}
|
|
425
520
|
this._releaseOverlay();
|
|
426
521
|
super.destroy();
|
|
522
|
+
this.#destroyed = true;
|
|
427
523
|
}
|
|
428
524
|
|
|
429
525
|
/** @param {string|number} width @returns {void} */
|
|
@@ -449,9 +545,11 @@ export class Modal extends Component {
|
|
|
449
545
|
*/
|
|
450
546
|
|
|
451
547
|
/**
|
|
452
|
-
* Fired when
|
|
548
|
+
* Fired when the reader asks to dismiss the modal — Escape, a header close button, a `'cancel'`
|
|
549
|
+
* footer button, a backdrop click, a press outside a non-modal overlay, a drag — with the gesture
|
|
550
|
+
* in `detail.reason`. Preventing it keeps the modal open. A programmatic `close()` does not raise it.
|
|
453
551
|
* @event Modal#cancel
|
|
454
|
-
* @type {CustomEvent<
|
|
552
|
+
* @type {CustomEvent<ModalCancelDetail>}
|
|
455
553
|
*/
|
|
456
554
|
|
|
457
555
|
/**
|
|
@@ -496,21 +594,22 @@ function isFocusable(element, root) {
|
|
|
496
594
|
}
|
|
497
595
|
|
|
498
596
|
/**
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
597
|
+
* The modal dialog an Escape keydown belongs to.
|
|
598
|
+
*
|
|
599
|
+
* Everything outside the topmost modal dialog is inert, so a key pressed inside an open modal
|
|
600
|
+
* dialog was pressed in the topmost one — whoever opened it, the library or the application.
|
|
601
|
+
* A key with no such dialog around it (focus on a popup above the dialog, or lost to the body)
|
|
602
|
+
* goes to the modal opened last, which is the overlay stack's order. Document order cannot answer
|
|
603
|
+
* either: a dialog constructed early sits before one constructed later wherever it opens.
|
|
604
|
+
* @param {KeyboardEvent} event Escape keydown.
|
|
605
|
+
* @returns {Element|null}
|
|
502
606
|
*/
|
|
503
|
-
function
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
target.append(document.createTextNode(String(content)));
|
|
508
|
-
} else if (typeof content.toElement === 'function') {
|
|
509
|
-
const element = content.toElement();
|
|
510
|
-
if (element) target.append(element);
|
|
511
|
-
} else if (typeof content.nodeType === 'number') {
|
|
512
|
-
target.append(content);
|
|
607
|
+
function topmostModalFor(event) {
|
|
608
|
+
const path = typeof event.composedPath === 'function' ? event.composedPath() : [];
|
|
609
|
+
for (let node = /** @type {any} */ (path[0] ?? event.target); node; node = node.parentNode ?? node.host ?? null) {
|
|
610
|
+
if (node.localName === 'dialog' && matchesState(node, ':modal')) return node;
|
|
513
611
|
}
|
|
612
|
+
return overlayStack.topmostModal();
|
|
514
613
|
}
|
|
515
614
|
|
|
516
615
|
/** @param {HTMLDialogElement} dialog @param {MouseEvent} event @returns {boolean} */
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The platform calls the overlays are built on, each behind a support check. Where a method is
|
|
3
|
+
* missing — a DOM implementation used for unit tests, such as jsdom, has `<dialog>` but neither
|
|
4
|
+
* `showModal()` nor `showPopover()` — the overlay falls back to the `open` attribute, which is what
|
|
5
|
+
* the stylesheet and `isOpen()` read either way. The fallback has no top layer, no inertness and
|
|
6
|
+
* no backdrop; it keeps the lifecycle (`open`, `close`, the result, `destroy()`) working.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Asks a state pseudo-class of an element. A selector engine that does not know `:modal` or
|
|
11
|
+
* `:popover-open` throws on it; there the element is in neither state.
|
|
12
|
+
* @param {Element|null|undefined} element Element to ask.
|
|
13
|
+
* @param {string} selector A selector such as `':modal'` or `':popover-open'`.
|
|
14
|
+
* @returns {boolean}
|
|
15
|
+
*/
|
|
16
|
+
export function matchesState(element, selector) {
|
|
17
|
+
if (!element || typeof element.matches !== 'function') return false;
|
|
18
|
+
try {
|
|
19
|
+
return element.matches(selector);
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The open modal dialogs of a document, in document order; empty where `:modal` is unknown.
|
|
27
|
+
* @param {Document} doc Document to search.
|
|
28
|
+
* @returns {Element[]}
|
|
29
|
+
*/
|
|
30
|
+
export function modalDialogs(doc) {
|
|
31
|
+
try {
|
|
32
|
+
return Array.from(doc.querySelectorAll('dialog:modal'));
|
|
33
|
+
} catch {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Whether a dialog is presented, by the reflected `open` property or the attribute itself.
|
|
40
|
+
* @param {Element} dialog Dialog element.
|
|
41
|
+
* @returns {boolean}
|
|
42
|
+
*/
|
|
43
|
+
export function isDialogOpen(dialog) {
|
|
44
|
+
return Boolean(/** @type {HTMLDialogElement} */ (dialog).open) || dialog.hasAttribute('open');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Presents a dialog modally with `showModal()`, or with the `open` attribute where it is missing.
|
|
49
|
+
* @param {Element} dialog Dialog element.
|
|
50
|
+
* @returns {boolean} Whether the platform presented it; false for the attribute fallback.
|
|
51
|
+
*/
|
|
52
|
+
export function showDialogModal(dialog) {
|
|
53
|
+
const element = /** @type {HTMLDialogElement} */ (dialog);
|
|
54
|
+
if (typeof element.showModal === 'function') {
|
|
55
|
+
element.showModal();
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
element.setAttribute('open', '');
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Presents a dialog non-modally with `show()`, or with the `open` attribute where it is missing.
|
|
64
|
+
* @param {Element} dialog Dialog element.
|
|
65
|
+
* @returns {void}
|
|
66
|
+
*/
|
|
67
|
+
export function showDialog(dialog) {
|
|
68
|
+
const element = /** @type {HTMLDialogElement} */ (dialog);
|
|
69
|
+
if (typeof element.show === 'function') element.show();
|
|
70
|
+
else element.setAttribute('open', '');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Closes a dialog with `close()`. Where it is missing the `open` attribute is removed and the
|
|
75
|
+
* `close` event the platform would queue is queued here, so one listener settles both.
|
|
76
|
+
* @param {Element} dialog Dialog element.
|
|
77
|
+
* @param {string} [result] Native string return value.
|
|
78
|
+
* @returns {void}
|
|
79
|
+
*/
|
|
80
|
+
export function closeDialog(dialog, result) {
|
|
81
|
+
const element = /** @type {HTMLDialogElement} */ (dialog);
|
|
82
|
+
if (typeof element.close === 'function') {
|
|
83
|
+
if (result === undefined) element.close();
|
|
84
|
+
else element.close(result);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (!isDialogOpen(element)) return;
|
|
88
|
+
if (result !== undefined) element.returnValue = String(result);
|
|
89
|
+
element.removeAttribute('open');
|
|
90
|
+
queueMicrotask(() => element.dispatchEvent(new Event('close')));
|
|
91
|
+
}
|
|
@@ -264,6 +264,9 @@
|
|
|
264
264
|
|
|
265
265
|
.zx-module-bar__item[aria-disabled="true"] .zx-module-bar__tile,
|
|
266
266
|
.zx-module-bar__entry[aria-disabled="true"] .zx-module-bar__tile { opacity: .55; }
|
|
267
|
+
|
|
268
|
+
/* An agent module is its AgentAvatar at the size of the tile: no tint, no AppIcon behind it. */
|
|
269
|
+
.zx-module-bar__tile[data-agent] > .zx-agent-avatar { --zx-agent-avatar-size: var(--zx-module-bar-tile); }
|
|
267
270
|
.zx-module-bar__item[aria-disabled="true"]:hover,
|
|
268
271
|
.zx-module-bar__entry[aria-disabled="true"]:hover { background: transparent; }
|
|
269
272
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h } from '../../core/dom.js';
|
|
2
2
|
import { icon } from '../../core/icons.js';
|
|
3
3
|
import { isCssColor, uid } from '../../core/util.js';
|
|
4
|
-
import { AppRailPresenter, appNavIcon, normalizeAppItems } from '../../internal/app-rail.js';
|
|
4
|
+
import { AppRailPresenter, appNavAgentWord, appNavIcon, appNavName, normalizeAppItems } from '../../internal/app-rail.js';
|
|
5
5
|
import { APP_ICON_TONES, appIcon } from '../app-icon/app-icon.js';
|
|
6
6
|
import { Dropdown } from '../dropdown/dropdown.js';
|
|
7
7
|
import { Tooltip } from '../tooltip/tooltip.js';
|
|
@@ -15,6 +15,10 @@ import { Tooltip } from '../tooltip/tooltip.js';
|
|
|
15
15
|
* @property {string|number} id Stable module identifier.
|
|
16
16
|
* @property {string} label Module name: the tile's accessible name, tooltip, and catalogue label.
|
|
17
17
|
* @property {string|Node|{toElement: () => Node|null}|((context: Record<string, any>, item: AppNavItem) => Node|null)} [icon] Icon name, node, component, or factory.
|
|
18
|
+
* @property {import('../../internal/app-rail.js').AppNavAgent|true} [agent] Draws the module as an
|
|
19
|
+
* agent: an AgentAvatar in place of the tile, whatever the `appearance`, at rest, with its
|
|
20
|
+
* activity's word in the tile's accessible name. `tone` and `color` then do not apply; the
|
|
21
|
+
* avatar's own `tone` does.
|
|
18
22
|
* @property {ModuleTone} [tone] Identity colour from the theme's categorical tones.
|
|
19
23
|
* @property {string} [color] Identity colour as any CSS colour; takes precedence over `tone`.
|
|
20
24
|
* @property {string|number} [badge] Count or status badge.
|
|
@@ -288,7 +292,7 @@ export class ModuleBar extends AppRailPresenter {
|
|
|
288
292
|
super.destroy();
|
|
289
293
|
}
|
|
290
294
|
|
|
291
|
-
/** @param {Node|null} node @returns {boolean} @
|
|
295
|
+
/** @param {Node|null} node @returns {boolean} @protected */
|
|
292
296
|
_containsNode(node) {
|
|
293
297
|
return super._containsNode(node) || Boolean(node && this._catalogue?.getPanel().contains(node));
|
|
294
298
|
}
|
|
@@ -450,6 +454,10 @@ export class ModuleBar extends AppRailPresenter {
|
|
|
450
454
|
level: 1,
|
|
451
455
|
location: location === 'bar' ? 'module' : 'catalogue'
|
|
452
456
|
}) ?? h('span', { class: 'zx-module-bar__initial' }, item.label.trim().charAt(0).toUpperCase());
|
|
457
|
+
if (visual instanceof Element && visual.classList.contains('zx-agent-avatar')) {
|
|
458
|
+
// An agent is its own identity: no tint, no AppIcon, the face at the size of the tile.
|
|
459
|
+
return h('span', { class: 'zx-module-bar__tile', ariaHidden: 'true', dataset: { agent: '' } }, visual);
|
|
460
|
+
}
|
|
453
461
|
const { tone, color } = resolveModuleColor(item);
|
|
454
462
|
const tile = h('span', {
|
|
455
463
|
class: 'zx-module-bar__tile',
|
|
@@ -476,8 +484,9 @@ export class ModuleBar extends AppRailPresenter {
|
|
|
476
484
|
_applyTileBadge(control, item) {
|
|
477
485
|
control.querySelector(':scope > .zx-module-bar__badge')?.remove();
|
|
478
486
|
const count = item.badge == null || item.badge === '' ? null : String(item.badge);
|
|
479
|
-
control.
|
|
480
|
-
|
|
487
|
+
const name = appNavName(item, control.querySelector('.zx-module-bar__tile > .zx-agent-avatar'));
|
|
488
|
+
control.setAttribute('aria-label', count === null ? name
|
|
489
|
+
: this._message('moduleBar.itemBadge', '%1 (%2)', name, count));
|
|
481
490
|
if (count === null) return;
|
|
482
491
|
control.append(h('span', {
|
|
483
492
|
class: 'zx-module-bar__badge',
|
|
@@ -1030,6 +1039,10 @@ function currentState(item, activeId) {
|
|
|
1030
1039
|
* @returns {void}
|
|
1031
1040
|
*/
|
|
1032
1041
|
function applyRowBadge(control, item, block) {
|
|
1042
|
+
// An agent row is named with its activity and count, so the name follows the badge.
|
|
1043
|
+
const agent = control.querySelector(
|
|
1044
|
+
':scope > .zx-module-bar__tile > .zx-agent-avatar, :scope > .zx-app-rail__flyout-item-icon > .zx-agent-avatar');
|
|
1045
|
+
if (appNavAgentWord(agent)) control.setAttribute('aria-label', appNavName(item, agent, true));
|
|
1033
1046
|
const existing = control.querySelector(`:scope > .${block}-badge`);
|
|
1034
1047
|
const count = item.badge == null || item.badge === '' ? null : String(item.badge);
|
|
1035
1048
|
if (count === null) {
|
|
@@ -87,8 +87,13 @@
|
|
|
87
87
|
color: var(--zx-color-text-muted);
|
|
88
88
|
cursor: grab;
|
|
89
89
|
touch-action: none;
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
93
|
+
.zx-multi-value-editor__handle {
|
|
94
|
+
transition: color var(--zx-dur-fast) var(--zx-ease),
|
|
95
|
+
background-color var(--zx-dur-fast) var(--zx-ease);
|
|
96
|
+
}
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
.zx-multi-value-editor__handle:hover:not(:disabled) {
|
|
@@ -22,6 +22,7 @@ const REORDER = Object.freeze({
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
/** Focusable parts of a row, so a re-render can put focus back where the reader left it. */
|
|
25
|
+
/** @typedef {'value'|'handle'|'up'|'down'} MultiValueEditorPart A row control that can take focus. */
|
|
25
26
|
const PARTS = Object.freeze({
|
|
26
27
|
value: '.zx-multi-value-editor__value',
|
|
27
28
|
handle: '.zx-multi-value-editor__handle',
|
|
@@ -109,7 +110,7 @@ export class MultiValueEditor extends Component {
|
|
|
109
110
|
|
|
110
111
|
/**
|
|
111
112
|
* @param {number} [focusIndex=-1] Row to focus after the render, or -1 for none.
|
|
112
|
-
* @param {
|
|
113
|
+
* @param {MultiValueEditorPart} [focusPart='value'] Which control of that row takes focus.
|
|
113
114
|
* @returns {void}
|
|
114
115
|
*/
|
|
115
116
|
_renderRows(focusIndex = -1, focusPart = 'value') {
|
|
@@ -346,7 +347,7 @@ export class MultiValueEditor extends Component {
|
|
|
346
347
|
/**
|
|
347
348
|
* @param {number} from Index to move.
|
|
348
349
|
* @param {number} to Destination index.
|
|
349
|
-
* @param {
|
|
350
|
+
* @param {MultiValueEditorPart} part Control of the moved row that takes focus.
|
|
350
351
|
* @returns {boolean} Whether anything moved.
|
|
351
352
|
*/
|
|
352
353
|
_move(from, to, part) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Component } from '../../core/component.js';
|
|
2
2
|
import { h } from '../../core/dom.js';
|
|
3
|
+
import { rovingStep } from '../../core/keyboard.js';
|
|
3
4
|
import { isElement, uid } from '../../core/util.js';
|
|
4
5
|
import { button } from '../button/button.js';
|
|
5
6
|
import { MenuButton } from '../menu-button/menu-button.js';
|
|
@@ -394,7 +395,9 @@ export class NavigationBar extends Component {
|
|
|
394
395
|
const enabled = this._enabledItems();
|
|
395
396
|
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
|
|
396
397
|
event.preventDefault();
|
|
397
|
-
|
|
398
|
+
// The arrows follow the visual order, which `dir="rtl"` reverses.
|
|
399
|
+
const step = rovingStep(event.key, 'horizontal', isRightToLeft(this.refs.items));
|
|
400
|
+
const offset = step === 'next' ? 1 : -1;
|
|
398
401
|
const index = enabled.indexOf(current);
|
|
399
402
|
const next = enabled[(index + offset + enabled.length) % enabled.length];
|
|
400
403
|
if (next) this._focusTab(next);
|
|
@@ -591,6 +594,15 @@ export function lengthToPixels(length, rootFontSize = 16) {
|
|
|
591
594
|
return size * (Number.isFinite(root) && root > 0 ? root : 16);
|
|
592
595
|
}
|
|
593
596
|
|
|
597
|
+
/**
|
|
598
|
+
* Whether an element is laid out right to left, as its computed `direction` says.
|
|
599
|
+
* @param {Element} element Element to ask.
|
|
600
|
+
* @returns {boolean}
|
|
601
|
+
*/
|
|
602
|
+
function isRightToLeft(element) {
|
|
603
|
+
return globalThis.getComputedStyle?.(element)?.direction === 'rtl';
|
|
604
|
+
}
|
|
605
|
+
|
|
594
606
|
/** @param {unknown} content @returns {content is NavigationPanelContent} */
|
|
595
607
|
function isPanelContent(content) {
|
|
596
608
|
if (typeof content === 'function' || content instanceof Component) return true;
|
|
@@ -23,6 +23,9 @@ export function registerNumberFieldAdapter() {
|
|
|
23
23
|
});
|
|
24
24
|
return {
|
|
25
25
|
el: numberField.el,
|
|
26
|
+
// The spinbutton, not the frame around it and its step buttons, is what the label names and
|
|
27
|
+
// what the field's description and validity belong to.
|
|
28
|
+
labelTarget: numberField.getInput(),
|
|
26
29
|
get: () => numberField.get(),
|
|
27
30
|
set: (value) => {
|
|
28
31
|
setting = true;
|