@zeyos/zx 4.4.0 → 5.2.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 +447 -0
- package/README.md +44 -11
- package/dist/types/components/account-menu/account-menu.d.ts +8 -0
- package/dist/types/components/activity-list/activity-list.d.ts +31 -1
- package/dist/types/components/app-icon/app-icon.d.ts +14 -2
- package/dist/types/components/app-sidebar/app-sidebar.d.ts +293 -17
- package/dist/types/components/avatar/avatar.d.ts +46 -7
- package/dist/types/components/badge/badge.d.ts +21 -1
- package/dist/types/components/button/button.d.ts +15 -0
- package/dist/types/components/calendar/calendar.d.ts +67 -5
- package/dist/types/components/card-view/card-view.d.ts +7 -4
- package/dist/types/components/card-view/record-card.d.ts +11 -0
- package/dist/types/components/chart/chart.d.ts +10 -0
- package/dist/types/components/checklist/checklist.d.ts +9 -0
- package/dist/types/components/code-editor/code-editor.d.ts +6 -17
- package/dist/types/components/context-menu/context-menu.d.ts +6 -2
- package/dist/types/components/data-filter/data-filter.d.ts +4 -4
- package/dist/types/components/datebox/date-range-box.d.ts +5 -1
- package/dist/types/components/datebox/datebox.d.ts +7 -2
- package/dist/types/components/dialog/dialog.d.ts +46 -6
- package/dist/types/components/dropdown/dropdown.d.ts +24 -9
- package/dist/types/components/entity-ref/entity-ref.d.ts +2 -2
- package/dist/types/components/field/field.d.ts +54 -2
- package/dist/types/components/fieldset/external-adapter.d.ts +83 -0
- package/dist/types/components/fieldset/fieldset.d.ts +26 -1
- package/dist/types/components/file-item/file-item.d.ts +34 -6
- package/dist/types/components/file-list/file-list.d.ts +35 -3
- package/dist/types/components/filter/filter.d.ts +127 -3
- package/dist/types/components/filter-panel/filter-panel.d.ts +36 -7
- package/dist/types/components/form/form.d.ts +12 -1
- package/dist/types/components/kanban-view/kanban-card.d.ts +8 -0
- package/dist/types/components/launcher/launcher.d.ts +268 -15
- package/dist/types/components/list-toolbar/list-toolbar.d.ts +16 -7
- package/dist/types/components/menu-button/menu-button.d.ts +39 -5
- package/dist/types/components/message/message.d.ts +132 -17
- package/dist/types/components/modal/modal.d.ts +43 -2
- package/dist/types/components/module-bar/module-bar.d.ts +395 -0
- package/dist/types/components/pagination/pagination.d.ts +17 -3
- package/dist/types/components/select/color.d.ts +12 -0
- package/dist/types/components/select/glyphs.d.ts +124 -0
- package/dist/types/components/select/select.d.ts +17 -3
- package/dist/types/components/sheet/sheet.d.ts +15 -0
- package/dist/types/components/stat-tile/stat-tile.d.ts +16 -5
- package/dist/types/components/tabbox/tabbox.d.ts +9 -0
- package/dist/types/components/table/table.d.ts +311 -18
- package/dist/types/components/tag-picker/tag-picker.d.ts +21 -4
- package/dist/types/components/tree/tree.d.ts +13 -0
- package/dist/types/components/view/record-view.d.ts +59 -2
- package/dist/types/components/view-settings/view-settings.d.ts +879 -0
- package/dist/types/components/workspace-switcher/workspace-switcher.d.ts +327 -0
- package/dist/types/core/breakpoint.d.ts +1 -1
- package/dist/types/core/component.d.ts +12 -2
- package/dist/types/core/i18n.d.ts +27 -3
- package/dist/types/core/icons.d.ts +23 -25
- package/dist/types/core/keyboard.d.ts +98 -1
- package/dist/types/core/messages.d.ts +382 -0
- package/dist/types/core/motion.d.ts +59 -0
- package/dist/types/core/overlay-host.d.ts +42 -1
- package/dist/types/core/overlay-stack.d.ts +260 -0
- package/dist/types/index.d.ts +10 -5
- package/dist/types/internal/app-rail.d.ts +38 -0
- package/dist/types/internal/menu-items.d.ts +71 -3
- package/dist/types/zeyos/connect.d.ts +6 -0
- package/dist/types/zeyos/form.d.ts +50 -9
- package/dist/types/zeyos/index.d.ts +2 -1
- package/dist/types/zeyos/launcher.d.ts +9 -0
- package/dist/types/zeyos/module-bar.d.ts +176 -0
- package/dist/types/zeyos/query.d.ts +110 -5
- package/dist/types/zeyos/schema.d.ts +24 -1
- package/dist/types/zeyos/table.d.ts +345 -22
- package/dist/types/zeyos/view.d.ts +26 -2
- package/dist/zx-zeyos.esm.js +6178 -1008
- package/dist/zx-zeyos.esm.min.js +53 -5
- package/dist/zx.css +2861 -827
- package/dist/zx.esm.js +8909 -1480
- package/dist/zx.esm.min.js +55 -7
- package/dist/zx.global.js +8911 -1482
- package/dist/zx.global.min.js +55 -7
- package/dist/zx.min.css +1 -1
- package/docs/api.json +1079 -117
- package/docs/llms.md +956 -154
- package/docs/llms.txt +9 -5
- package/package.json +1 -1
- package/src/components/account-menu/account-menu.css +35 -10
- package/src/components/account-menu/account-menu.js +12 -0
- package/src/components/activity-item/activity-item.css +1 -1
- package/src/components/activity-item/activity-item.js +3 -0
- package/src/components/activity-list/activity-list.css +38 -3
- package/src/components/activity-list/activity-list.js +61 -1
- package/src/components/app-icon/app-icon.css +14 -3
- package/src/components/app-icon/app-icon.js +11 -1
- package/src/components/app-rail/app-rail.css +59 -79
- package/src/components/app-sidebar/app-sidebar.css +304 -168
- package/src/components/app-sidebar/app-sidebar.js +667 -46
- package/src/components/aurora/aurora.css +5 -3
- package/src/components/avatar/avatar.css +32 -7
- package/src/components/avatar/avatar.js +72 -8
- package/src/components/badge/badge.css +54 -2
- package/src/components/badge/badge.js +29 -2
- package/src/components/breadcrumb/breadcrumb.css +1 -1
- package/src/components/button/button.css +67 -9
- package/src/components/button/button.js +38 -0
- package/src/components/calendar/calendar.css +47 -47
- package/src/components/calendar/calendar.js +26 -52
- package/src/components/card/card.css +4 -4
- package/src/components/card-view/card-view.css +14 -12
- package/src/components/card-view/card-view.js +13 -9
- package/src/components/card-view/record-card.js +14 -3
- package/src/components/chart/chart.css +4 -1
- package/src/components/chart/chart.js +12 -0
- package/src/components/check-button/check-button.css +10 -2
- package/src/components/checklist/checklist.css +9 -2
- package/src/components/checklist/checklist.js +11 -5
- package/src/components/checklist/field-adapter.js +3 -1
- package/src/components/code-editor/code-editor.css +7 -6
- package/src/components/code-editor/code-editor.js +19 -1
- package/src/components/code-editor/field-adapter.js +9 -2
- package/src/components/context-menu/context-menu.css +9 -4
- package/src/components/context-menu/context-menu.js +8 -2
- package/src/components/copy/copy-button.css +6 -0
- package/src/components/copy/copy-input.css +9 -4
- package/src/components/data-filter/data-filter.css +5 -4
- package/src/components/data-filter/data-filter.js +2 -2
- package/src/components/date-picker/date-picker.css +6 -6
- package/src/components/date-picker/date-range-picker.css +3 -3
- package/src/components/date-picker/time-picker.css +3 -3
- package/src/components/datebox/date-range-box.css +79 -2
- package/src/components/datebox/date-range-box.js +13 -2
- package/src/components/datebox/datebox.css +79 -2
- package/src/components/datebox/datebox.js +13 -2
- package/src/components/dialog/dialog.css +26 -0
- package/src/components/dialog/dialog.js +99 -17
- package/src/components/dock/dock.css +5 -4
- package/src/components/dropdown/dropdown.css +1 -1
- package/src/components/dropdown/dropdown.js +159 -72
- package/src/components/empty-state/empty-state.css +2 -2
- package/src/components/entity-ref/entity-ref.css +1 -1
- package/src/components/entity-ref/entity-ref.js +1 -1
- package/src/components/field/field.css +28 -9
- package/src/components/field/field.js +101 -29
- package/src/components/field-upload/field-upload.css +1 -1
- package/src/components/fieldset/external-adapter.js +363 -0
- package/src/components/fieldset/fieldset.css +5 -3
- package/src/components/fieldset/fieldset.js +38 -64
- package/src/components/file-item/file-item.js +144 -10
- package/src/components/file-list/file-list.js +144 -21
- package/src/components/filter/filter.css +86 -2
- package/src/components/filter/filter.js +307 -11
- package/src/components/filter-panel/filter-panel.css +1 -1
- package/src/components/filter-panel/filter-panel.js +149 -32
- package/src/components/finder/finder.css +16 -14
- package/src/components/form/form.css +5 -4
- package/src/components/form/form.js +11 -2
- package/src/components/grid/grid.css +1 -1
- package/src/components/groupbox/groupbox.css +1 -1
- package/src/components/kanban-view/kanban-card.js +11 -3
- package/src/components/kanban-view/kanban-view.css +42 -18
- package/src/components/kanban-view/kanban-view.js +9 -6
- package/src/components/launcher/launcher.css +108 -26
- package/src/components/launcher/launcher.js +530 -42
- package/src/components/list-toolbar/list-toolbar.css +13 -8
- package/src/components/list-toolbar/list-toolbar.js +40 -14
- package/src/components/master-panel/master-panel.css +2 -0
- package/src/components/master-panel/master-panel.js +0 -1
- package/src/components/menu-button/menu-button.css +72 -4
- package/src/components/menu-button/menu-button.js +160 -18
- package/src/components/message/message.css +33 -3
- package/src/components/message/message.js +264 -22
- package/src/components/modal/modal.css +1 -1
- package/src/components/modal/modal.js +83 -15
- package/src/components/module-bar/module-bar.css +486 -0
- package/src/components/module-bar/module-bar.js +1074 -0
- package/src/components/multi-value-editor/multi-value-editor.css +1 -1
- package/src/components/navigation-bar/navigation-bar.css +18 -9
- package/src/components/number-field/field-adapter.js +3 -1
- package/src/components/number-field/number-field.css +70 -0
- package/src/components/number-field/number-field.js +2 -0
- package/src/components/pagination/pagination.css +13 -11
- package/src/components/pagination/pagination.js +20 -4
- package/src/components/panel/panel.css +4 -3
- package/src/components/questionnaire/questionnaire.css +4 -4
- package/src/components/rating/field-adapter.js +2 -1
- package/src/components/rating/rating.css +8 -1
- package/src/components/search/search.css +4 -1
- package/src/components/select/color.js +22 -0
- package/src/components/select/field-adapter.js +2 -0
- package/src/components/select/glyphs.js +165 -0
- package/src/components/select/select.css +138 -45
- package/src/components/select/select.js +92 -47
- package/src/components/sheet/sheet.css +12 -9
- package/src/components/sheet/sheet.js +74 -32
- package/src/components/slider/field-adapter.js +6 -1
- package/src/components/slider/slider.css +18 -4
- package/src/components/slider/slider.js +1 -1
- package/src/components/sort-control/sort-control.css +4 -1
- package/src/components/split-view/split-view.css +1 -1
- package/src/components/stat-tile/stat-tile.css +42 -47
- package/src/components/stat-tile/stat-tile.js +17 -6
- package/src/components/stepper/stepper.css +1 -1
- package/src/components/tabbox/tabbox.css +41 -32
- package/src/components/tabbox/tabbox.js +5 -1
- package/src/components/table/table.css +187 -37
- package/src/components/table/table.js +718 -73
- package/src/components/tag-picker/field-adapter.js +2 -1
- package/src/components/tag-picker/tag-picker.css +83 -5
- package/src/components/tag-picker/tag-picker.js +25 -8
- package/src/components/timebox/timebox.css +22 -2
- package/src/components/toggle/toggle.css +12 -1
- package/src/components/toolbar/toolbar.js +2 -2
- package/src/components/tooltip/tooltip.css +4 -0
- package/src/components/tooltip/tooltip.js +44 -19
- package/src/components/tree/tree.css +26 -17
- package/src/components/tree/tree.js +31 -0
- package/src/components/value-list/value-list.css +3 -3
- package/src/components/view/record-view.css +1 -1
- package/src/components/view/record-view.js +178 -18
- package/src/components/view-settings/view-settings.css +285 -0
- package/src/components/view-settings/view-settings.js +1830 -0
- package/src/components/workspace-switcher/workspace-switcher.css +188 -0
- package/src/components/workspace-switcher/workspace-switcher.js +463 -0
- package/src/core/breakpoint.js +1 -1
- package/src/core/component.js +88 -17
- package/src/core/fontawesome.js +5 -1
- package/src/core/i18n.js +47 -4
- package/src/core/icons.js +204 -61
- package/src/core/keyboard.js +206 -11
- package/src/core/messages.js +427 -0
- package/src/core/motion.js +147 -0
- package/src/core/overlay-host.js +77 -3
- package/src/core/overlay-stack.js +487 -0
- package/src/core/position.js +22 -3
- package/src/index.js +10 -5
- package/src/internal/app-rail.js +135 -55
- package/src/internal/menu-items.js +61 -3
- package/src/zeyos/connect.js +6 -2
- package/src/zeyos/form.js +69 -27
- package/src/zeyos/index.js +4 -1
- package/src/zeyos/launcher.js +8 -3
- package/src/zeyos/module-bar.js +181 -0
- package/src/zeyos/query.js +197 -13
- package/src/zeyos/schema.js +144 -27
- package/src/zeyos/table.js +287 -84
- package/src/zeyos/view.js +49 -93
- package/styles/base.css +72 -1
- package/styles/icons.css +11 -1
- package/styles/print.css +1 -1
- package/styles/tokens/dark.css +117 -37
- package/styles/tokens/global.css +121 -27
- package/styles/tokens/semantic.css +140 -43
- package/styles/tokens/themes.css +7 -6
- package/styles/zx.css +3 -1
- package/styles/tokens/density.css +0 -9
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { Component } from '../../core/component.js';
|
|
2
|
+
import { MenuButton } from '../menu-button/menu-button.js';
|
|
3
|
+
export type MenuButtonItem = import('../menu-button/menu-button.js').MenuButtonItem;
|
|
4
|
+
export type AppIconTone = import('../app-icon/app-icon.js').AppIconTone;
|
|
5
|
+
export type WorkspaceItem = {
|
|
6
|
+
/**
|
|
7
|
+
* Stable identifier; the `active` option and `setActive()` name it.
|
|
8
|
+
*/
|
|
9
|
+
id: string | number;
|
|
10
|
+
/**
|
|
11
|
+
* Workspace name.
|
|
12
|
+
*/
|
|
13
|
+
label: string;
|
|
14
|
+
/**
|
|
15
|
+
* Secondary line: plan, role, domain.
|
|
16
|
+
*/
|
|
17
|
+
secondary?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Icon name or node drawn on the tile instead of the initial. A node
|
|
20
|
+
* is cloned for each place the tile appears.
|
|
21
|
+
*/
|
|
22
|
+
icon?: string | Node;
|
|
23
|
+
/**
|
|
24
|
+
* Tile colour from the theme's categorical palette. Without `tone`
|
|
25
|
+
* or `color` the tone is derived from the label, so a workspace keeps its colour everywhere.
|
|
26
|
+
*/
|
|
27
|
+
tone?: AppIconTone;
|
|
28
|
+
/**
|
|
29
|
+
* Tile colour, any CSS colour; takes precedence over `tone`.
|
|
30
|
+
*/
|
|
31
|
+
color?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Image drawn as the tile instead of the initial or icon.
|
|
34
|
+
*/
|
|
35
|
+
src?: string | null;
|
|
36
|
+
/**
|
|
37
|
+
* Explicit tile initials; derived from the label when omitted.
|
|
38
|
+
*/
|
|
39
|
+
initials?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Compact trailing metadata in the menu, such as an unread count.
|
|
42
|
+
*/
|
|
43
|
+
badge?: string | number;
|
|
44
|
+
/**
|
|
45
|
+
* Whether the workspace is listed but cannot be chosen.
|
|
46
|
+
*/
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
};
|
|
49
|
+
export type WorkspaceSwitcherSelectDetail = {
|
|
50
|
+
/**
|
|
51
|
+
* The workspace being switched to.
|
|
52
|
+
*/
|
|
53
|
+
workspace: WorkspaceItem;
|
|
54
|
+
/**
|
|
55
|
+
* Its id.
|
|
56
|
+
*/
|
|
57
|
+
id: string | number;
|
|
58
|
+
/**
|
|
59
|
+
* The workspace active until now.
|
|
60
|
+
*/
|
|
61
|
+
previous: WorkspaceItem | null;
|
|
62
|
+
};
|
|
63
|
+
export type WorkspaceSwitcherOptions = {
|
|
64
|
+
/**
|
|
65
|
+
* Workspaces in menu order. Entries without an id are
|
|
66
|
+
* skipped, and a repeated id keeps its first entry.
|
|
67
|
+
*/
|
|
68
|
+
workspaces?: WorkspaceItem[];
|
|
69
|
+
/**
|
|
70
|
+
* Active workspace id. Defaults to the first enabled
|
|
71
|
+
* workspace, which also stands in for an id that is not listed or is disabled.
|
|
72
|
+
*/
|
|
73
|
+
active?: string | number | null;
|
|
74
|
+
/**
|
|
75
|
+
* Extra actions listed after the workspaces — "Create
|
|
76
|
+
* workspace", "Workspace settings", `'-'` separators, "Sign out". A separator is inserted
|
|
77
|
+
* between the workspaces and the actions automatically.
|
|
78
|
+
*/
|
|
79
|
+
items?: MenuButtonItem[];
|
|
80
|
+
/**
|
|
81
|
+
* Whether the trigger shows the tile alone.
|
|
82
|
+
*/
|
|
83
|
+
compact?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Group label above the workspaces; null resolves message
|
|
86
|
+
* `workspaceSwitcher.heading` ("Workspaces"), and an empty string leaves the label out.
|
|
87
|
+
*/
|
|
88
|
+
heading?: string | null;
|
|
89
|
+
/**
|
|
90
|
+
* Trigger accessible name, in which `%1` is the active
|
|
91
|
+
* workspace's name and is filled in again after every switch. Null resolves message
|
|
92
|
+
* `workspaceSwitcher.label` ("Switch workspace: %1"), or `workspaceSwitcher.labelEmpty`
|
|
93
|
+
* ("Switch workspace") while no workspace is active.
|
|
94
|
+
*/
|
|
95
|
+
label?: string | null;
|
|
96
|
+
/**
|
|
97
|
+
* Popup placement.
|
|
98
|
+
*/
|
|
99
|
+
placement?: 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end' | 'bottom' | 'top' | 'right-start' | 'right-end' | 'left-start' | 'left-end' | 'right' | 'left';
|
|
100
|
+
/**
|
|
101
|
+
* Preventable
|
|
102
|
+
* workspace switch; `preventDefault()` keeps the previous workspace active and the menu open.
|
|
103
|
+
*/
|
|
104
|
+
onselect?: (event: CustomEvent<WorkspaceSwitcherSelectDetail>) => void;
|
|
105
|
+
/**
|
|
106
|
+
* Preventable
|
|
107
|
+
* extra action; `preventDefault()` skips the item's own callback and keeps the menu open.
|
|
108
|
+
*/
|
|
109
|
+
onaction?: (event: CustomEvent<{
|
|
110
|
+
value: unknown;
|
|
111
|
+
item: object;
|
|
112
|
+
}>) => void;
|
|
113
|
+
/**
|
|
114
|
+
* Open listener.
|
|
115
|
+
*/
|
|
116
|
+
onopen?: (event: CustomEvent<Record<string, never>>) => void;
|
|
117
|
+
/**
|
|
118
|
+
* Close listener.
|
|
119
|
+
*/
|
|
120
|
+
onclose?: (event: CustomEvent<Record<string, never>>) => void;
|
|
121
|
+
/**
|
|
122
|
+
* Component-local message overrides, by key:
|
|
123
|
+
* `workspaceSwitcher.heading` ("Workspaces"), `workspaceSwitcher.label` ("Switch workspace: %1",
|
|
124
|
+
* `%1` the active workspace's name), and `workspaceSwitcher.labelEmpty` ("Switch workspace",
|
|
125
|
+
* the trigger's name while no workspace is active).
|
|
126
|
+
*/
|
|
127
|
+
msg?: Record<string, unknown>;
|
|
128
|
+
};
|
|
129
|
+
/** @typedef {import('../menu-button/menu-button.js').MenuButtonItem} MenuButtonItem */
|
|
130
|
+
/** @typedef {import('../app-icon/app-icon.js').AppIconTone} AppIconTone */
|
|
131
|
+
/**
|
|
132
|
+
* One workspace, account, or organisation the user can switch to.
|
|
133
|
+
* @typedef {Object} WorkspaceItem
|
|
134
|
+
* @property {string|number} id Stable identifier; the `active` option and `setActive()` name it.
|
|
135
|
+
* @property {string} label Workspace name.
|
|
136
|
+
* @property {string} [secondary] Secondary line: plan, role, domain.
|
|
137
|
+
* @property {string|Node} [icon] Icon name or node drawn on the tile instead of the initial. A node
|
|
138
|
+
* is cloned for each place the tile appears.
|
|
139
|
+
* @property {AppIconTone} [tone] Tile colour from the theme's categorical palette. Without `tone`
|
|
140
|
+
* or `color` the tone is derived from the label, so a workspace keeps its colour everywhere.
|
|
141
|
+
* @property {string} [color] Tile colour, any CSS colour; takes precedence over `tone`.
|
|
142
|
+
* @property {string|null} [src] Image drawn as the tile instead of the initial or icon.
|
|
143
|
+
* @property {string} [initials] Explicit tile initials; derived from the label when omitted.
|
|
144
|
+
* @property {string|number} [badge] Compact trailing metadata in the menu, such as an unread count.
|
|
145
|
+
* @property {boolean} [disabled=false] Whether the workspace is listed but cannot be chosen.
|
|
146
|
+
*/
|
|
147
|
+
/**
|
|
148
|
+
* @typedef {Object} WorkspaceSwitcherSelectDetail
|
|
149
|
+
* @property {WorkspaceItem} workspace The workspace being switched to.
|
|
150
|
+
* @property {string|number} id Its id.
|
|
151
|
+
* @property {WorkspaceItem|null} previous The workspace active until now.
|
|
152
|
+
*/
|
|
153
|
+
/**
|
|
154
|
+
* @typedef {Object} WorkspaceSwitcherOptions
|
|
155
|
+
* @property {WorkspaceItem[]} [workspaces=[]] Workspaces in menu order. Entries without an id are
|
|
156
|
+
* skipped, and a repeated id keeps its first entry.
|
|
157
|
+
* @property {string|number|null} [active=null] Active workspace id. Defaults to the first enabled
|
|
158
|
+
* workspace, which also stands in for an id that is not listed or is disabled.
|
|
159
|
+
* @property {MenuButtonItem[]} [items=[]] Extra actions listed after the workspaces — "Create
|
|
160
|
+
* workspace", "Workspace settings", `'-'` separators, "Sign out". A separator is inserted
|
|
161
|
+
* between the workspaces and the actions automatically.
|
|
162
|
+
* @property {boolean} [compact=false] Whether the trigger shows the tile alone.
|
|
163
|
+
* @property {string|null} [heading=null] Group label above the workspaces; null resolves message
|
|
164
|
+
* `workspaceSwitcher.heading` ("Workspaces"), and an empty string leaves the label out.
|
|
165
|
+
* @property {string|null} [label=null] Trigger accessible name, in which `%1` is the active
|
|
166
|
+
* workspace's name and is filled in again after every switch. Null resolves message
|
|
167
|
+
* `workspaceSwitcher.label` ("Switch workspace: %1"), or `workspaceSwitcher.labelEmpty`
|
|
168
|
+
* ("Switch workspace") while no workspace is active.
|
|
169
|
+
* @property {'bottom-start'|'bottom-end'|'top-start'|'top-end'|'bottom'|'top'|'right-start'|'right-end'|'left-start'|'left-end'|'right'|'left'} [placement='bottom-start'] Popup placement.
|
|
170
|
+
* @property {(event: CustomEvent<WorkspaceSwitcherSelectDetail>) => void} [onselect] Preventable
|
|
171
|
+
* workspace switch; `preventDefault()` keeps the previous workspace active and the menu open.
|
|
172
|
+
* @property {(event: CustomEvent<{value: unknown, item: object}>) => void} [onaction] Preventable
|
|
173
|
+
* extra action; `preventDefault()` skips the item's own callback and keeps the menu open.
|
|
174
|
+
* @property {(event: CustomEvent<Record<string, never>>) => void} [onopen] Open listener.
|
|
175
|
+
* @property {(event: CustomEvent<Record<string, never>>) => void} [onclose] Close listener.
|
|
176
|
+
* @property {Record<string, unknown>} [msg] Component-local message overrides, by key:
|
|
177
|
+
* `workspaceSwitcher.heading` ("Workspaces"), `workspaceSwitcher.label` ("Switch workspace: %1",
|
|
178
|
+
* `%1` the active workspace's name), and `workspaceSwitcher.labelEmpty` ("Switch workspace",
|
|
179
|
+
* the trigger's name while no workspace is active).
|
|
180
|
+
*/
|
|
181
|
+
/**
|
|
182
|
+
* Workspace switcher for the head of an application's navigation: a trigger with the current
|
|
183
|
+
* workspace's tile, name, and secondary line, opening an APG menu of the workspaces — the current
|
|
184
|
+
* one checked — followed by the application's own actions. Which workspaces a user may see, and
|
|
185
|
+
* what switching means, stay application-owned.
|
|
186
|
+
* @fires WorkspaceSwitcher#select
|
|
187
|
+
* @fires WorkspaceSwitcher#action
|
|
188
|
+
* @fires WorkspaceSwitcher#open
|
|
189
|
+
* @fires WorkspaceSwitcher#close
|
|
190
|
+
* @extends {Component<WorkspaceSwitcherOptions>}
|
|
191
|
+
*/
|
|
192
|
+
export declare class WorkspaceSwitcher extends Component<WorkspaceSwitcherOptions> {
|
|
193
|
+
_menu: MenuButton;
|
|
194
|
+
_createdRoot: boolean;
|
|
195
|
+
_snapshot: import("../../core/dom.js").TargetSnapshot;
|
|
196
|
+
_workspaces: WorkspaceItem[];
|
|
197
|
+
_activeId: string | number;
|
|
198
|
+
_items: import("../../internal/menu-items.js").MenuEntry[];
|
|
199
|
+
/** @type {Map<object, WorkspaceItem>} Menu entries that stand for a workspace. */
|
|
200
|
+
_entries: Map<object, WorkspaceItem>;
|
|
201
|
+
static cssName: string;
|
|
202
|
+
/** @type {Readonly<WorkspaceSwitcherOptions>} */
|
|
203
|
+
static defaults: Readonly<WorkspaceSwitcherOptions>;
|
|
204
|
+
/**
|
|
205
|
+
* Creates or enhances a workspace-switcher host.
|
|
206
|
+
* @param {Element|string|null} target Host target.
|
|
207
|
+
* @param {WorkspaceSwitcherOptions} [options={}] Workspace-switcher options.
|
|
208
|
+
*/
|
|
209
|
+
constructor(target?: Element | string | null, options?: WorkspaceSwitcherOptions);
|
|
210
|
+
/** @returns {HTMLElement} */
|
|
211
|
+
render(): HTMLElement;
|
|
212
|
+
/** Returns the active workspace, or null when no workspace is enabled. @returns {WorkspaceItem|null} */
|
|
213
|
+
getActive(): WorkspaceItem | null;
|
|
214
|
+
/**
|
|
215
|
+
* Makes another workspace active. An unknown or disabled id changes nothing.
|
|
216
|
+
* @param {string|number} id Workspace id.
|
|
217
|
+
* @param {{silent?: boolean}} [options={}] `silent: false` emits the preventable `select` first;
|
|
218
|
+
* by default the change is silent, as a change the application made itself.
|
|
219
|
+
* @returns {this}
|
|
220
|
+
* @fires WorkspaceSwitcher#select
|
|
221
|
+
*/
|
|
222
|
+
setActive(id: string | number, { silent }?: {
|
|
223
|
+
silent?: boolean;
|
|
224
|
+
}): this;
|
|
225
|
+
/**
|
|
226
|
+
* Replaces the workspaces. The active workspace stays active while it is still listed and
|
|
227
|
+
* enabled; otherwise the first enabled workspace becomes active, silently.
|
|
228
|
+
* @param {WorkspaceItem[]} workspaces Workspaces in menu order.
|
|
229
|
+
* @returns {this}
|
|
230
|
+
*/
|
|
231
|
+
setWorkspaces(workspaces: WorkspaceItem[]): this;
|
|
232
|
+
/** Replaces the extra actions after the workspaces. @param {MenuButtonItem[]} items @returns {this} */
|
|
233
|
+
setItems(items: MenuButtonItem[]): this;
|
|
234
|
+
/**
|
|
235
|
+
* Shows the tile alone, or the tile with the name, secondary line, and chevron — for a navigation
|
|
236
|
+
* column that narrows to icons and widens again. The trigger keeps its full accessible name and
|
|
237
|
+
* gains the workspace name as a tooltip while compact.
|
|
238
|
+
* @param {boolean} compact
|
|
239
|
+
* @returns {this}
|
|
240
|
+
*/
|
|
241
|
+
setCompact(compact: boolean): this;
|
|
242
|
+
/** Opens the menu. @returns {this} */
|
|
243
|
+
open(): this;
|
|
244
|
+
/** Closes the menu. @returns {this} */
|
|
245
|
+
close(): this;
|
|
246
|
+
/** Toggles the menu. @returns {this} */
|
|
247
|
+
toggle(): this;
|
|
248
|
+
/** Reports whether the menu is open. @returns {boolean} */
|
|
249
|
+
isOpen(): boolean;
|
|
250
|
+
/** Focuses the trigger. @returns {this} */
|
|
251
|
+
focus(): this;
|
|
252
|
+
/** Returns the menu panel for shell hover and focus coordination. @returns {HTMLElement} */
|
|
253
|
+
getPanel(): HTMLElement;
|
|
254
|
+
/** Destroys the menu and restores or removes the host. @returns {void} */
|
|
255
|
+
destroy(): void;
|
|
256
|
+
/** @returns {void} */
|
|
257
|
+
_sync(): void;
|
|
258
|
+
/** @returns {void} */
|
|
259
|
+
_renderTrigger(): void;
|
|
260
|
+
/** @returns {void} */
|
|
261
|
+
_renderMenu(): void;
|
|
262
|
+
/** @param {CustomEvent<{value: unknown, item: object}>} event @returns {void} */
|
|
263
|
+
_onMenuSelect(event: CustomEvent<{
|
|
264
|
+
value: unknown;
|
|
265
|
+
item: object;
|
|
266
|
+
}>): void;
|
|
267
|
+
/** @param {WorkspaceItem} workspace @returns {CustomEvent<WorkspaceSwitcherSelectDetail>} */
|
|
268
|
+
_emitSelect(workspace: WorkspaceItem): CustomEvent<WorkspaceSwitcherSelectDetail>;
|
|
269
|
+
/**
|
|
270
|
+
* Resolves a message, falling back to English when no translation is registered.
|
|
271
|
+
* @param {string} key Message key.
|
|
272
|
+
* @param {string} fallback English fallback with `%1` placeholders.
|
|
273
|
+
* @param {...unknown} args Interpolation values.
|
|
274
|
+
* @returns {string}
|
|
275
|
+
*/
|
|
276
|
+
_message(key: string, fallback: string, ...args: unknown[]): string;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Normalises one workspace definition: a string id or label, a tone the palette knows, a colour
|
|
280
|
+
* only when no tone was asked for, and initials derived from the label when none were given.
|
|
281
|
+
* @param {unknown} value Candidate workspace.
|
|
282
|
+
* @returns {(WorkspaceItem & {label: string, secondary: string, initials: string, disabled: boolean, tone: AppIconTone|null, color: string|null, src: string|null}) | null}
|
|
283
|
+
* The workspace, or null when it has no usable id.
|
|
284
|
+
*/
|
|
285
|
+
export declare function normalizeWorkspace(value: unknown): (WorkspaceItem & {
|
|
286
|
+
label: string;
|
|
287
|
+
secondary: string;
|
|
288
|
+
initials: string;
|
|
289
|
+
disabled: boolean;
|
|
290
|
+
tone: AppIconTone | null;
|
|
291
|
+
color: string | null;
|
|
292
|
+
src: string | null;
|
|
293
|
+
}) | null;
|
|
294
|
+
/**
|
|
295
|
+
* Normalises a workspace list, skipping entries without an id and repeats of an id already listed.
|
|
296
|
+
* @param {unknown} list Candidate workspaces.
|
|
297
|
+
* @returns {WorkspaceItem[]}
|
|
298
|
+
*/
|
|
299
|
+
export declare function normalizeWorkspaces(list: unknown): WorkspaceItem[];
|
|
300
|
+
/**
|
|
301
|
+
* Resolves the active workspace id: the requested one when it is listed and enabled, otherwise the
|
|
302
|
+
* first enabled workspace, otherwise null. Ids compare as strings, so `3` finds `'3'`.
|
|
303
|
+
* @param {WorkspaceItem[]} workspaces Normalised workspaces.
|
|
304
|
+
* @param {string|number|null|undefined} active Requested id.
|
|
305
|
+
* @returns {string|number|null}
|
|
306
|
+
*/
|
|
307
|
+
export declare function resolveActive(workspaces: WorkspaceItem[], active: string | number | null | undefined): string | number | null;
|
|
308
|
+
/**
|
|
309
|
+
* The tile initials for a workspace: explicit initials trimmed to two characters, otherwise the
|
|
310
|
+
* first letter of the label, uppercased.
|
|
311
|
+
* @param {unknown} label Workspace name.
|
|
312
|
+
* @param {unknown} [initials] Explicit initials.
|
|
313
|
+
* @returns {string}
|
|
314
|
+
*/
|
|
315
|
+
export declare function workspaceInitials(label: unknown, initials?: unknown): string;
|
|
316
|
+
/**
|
|
317
|
+
* Fills a custom trigger label: `%1` becomes the active workspace's name (empty while none is
|
|
318
|
+
* active), so the label follows every switch.
|
|
319
|
+
* @param {unknown} template Label, with an optional `%1`.
|
|
320
|
+
* @param {unknown} name Active workspace name.
|
|
321
|
+
* @returns {string}
|
|
322
|
+
*/
|
|
323
|
+
export declare function formatWorkspaceLabel(template: unknown, name: unknown): string;
|
|
324
|
+
/** Fired before the active workspace changes; preventable. @event WorkspaceSwitcher#select @type {CustomEvent<WorkspaceSwitcherSelectDetail>} */
|
|
325
|
+
/** Fired when an extra action is chosen; preventable. @event WorkspaceSwitcher#action @type {CustomEvent<{value: unknown, item: object}>} */
|
|
326
|
+
/** Fired after the menu opens. @event WorkspaceSwitcher#open @type {CustomEvent<Record<string, never>>} */
|
|
327
|
+
/** Fired after the menu closes. @event WorkspaceSwitcher#close @type {CustomEvent<Record<string, never>>} */
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* used inside a media query, so a `--zx-bp-*` token would be a value no stylesheet could read.
|
|
6
6
|
* Zx's own layout utilities avoid the problem entirely — `.zx-grid` reflows on intrinsic track
|
|
7
7
|
* widths, not on breakpoints — which leaves this module for the cases only script can decide:
|
|
8
|
-
* rendering a Table as cards below a width, collapsing a MasterPanel, choosing a chart
|
|
8
|
+
* rendering a Table as cards below a width, collapsing a MasterPanel, choosing how many labels a chart shows.
|
|
9
9
|
* @module zx/core/breakpoint
|
|
10
10
|
*/
|
|
11
11
|
export type BreakpointName = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
@@ -99,9 +99,19 @@ export declare class Component<TOptions extends ComponentOptions = ComponentOpti
|
|
|
99
99
|
*/
|
|
100
100
|
toElement(): Element;
|
|
101
101
|
/**
|
|
102
|
-
* Resolves and interpolates
|
|
102
|
+
* Resolves and interpolates one of the component's messages. The first answer wins:
|
|
103
|
+
*
|
|
104
|
+
* 1. the `msg` option this instance was given — a `{[lang]: {key: text}}` table for the active
|
|
105
|
+
* language (the `lang` option, else `getLanguage()`), then a flat `{key: text}` entry;
|
|
106
|
+
* 2. the host translator installed with `setTranslator()`;
|
|
107
|
+
* 3. the `msg` defaults the component class declares;
|
|
108
|
+
* 4. the default English catalogue (`defaultMessages`);
|
|
109
|
+
* 5. the key itself.
|
|
110
|
+
*
|
|
111
|
+
* A renamed key (`calendar.today`, formerly `today`) is also looked up under its former name,
|
|
112
|
+
* right after the new one, in steps 1 and 2.
|
|
103
113
|
* @param {string} key Message key.
|
|
104
|
-
* @param {...unknown} args Positional interpolation values.
|
|
114
|
+
* @param {...unknown} args Positional interpolation values (`%1`, `%2`, …).
|
|
105
115
|
* @returns {string}
|
|
106
116
|
*/
|
|
107
117
|
msg(key: string, ...args: unknown[]): string;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { defaultMessages } from './messages.js';
|
|
2
|
+
export { defaultMessages };
|
|
2
3
|
export type Translator = (key: string) => string | null | undefined;
|
|
3
4
|
/**
|
|
4
|
-
* Installs the host application's translation function, or clears it with null.
|
|
5
|
+
* Installs the host application's translation function, or clears it with null. The function
|
|
6
|
+
* answers one key at a time; returning null, undefined, or the key itself means "no translation",
|
|
7
|
+
* and resolution moves on to the default English catalogue (`defaultMessages`).
|
|
5
8
|
* @param {Translator|null} fn Translator function.
|
|
6
9
|
* @returns {void}
|
|
7
10
|
*/
|
|
@@ -18,7 +21,28 @@ export declare function setLanguage(lang: string): void;
|
|
|
18
21
|
*/
|
|
19
22
|
export declare function getLanguage(): string;
|
|
20
23
|
/**
|
|
21
|
-
*
|
|
24
|
+
* Asks the host translator for one key, without interpolating. A translator that returns null,
|
|
25
|
+
* undefined, or the key itself has no answer.
|
|
26
|
+
* @param {string} key Message key.
|
|
27
|
+
* @returns {string|null} The translation, or null when there is none.
|
|
28
|
+
*/
|
|
29
|
+
export declare function hostMessage(key: string): string | null;
|
|
30
|
+
/**
|
|
31
|
+
* Looks one key up in the default English catalogue.
|
|
32
|
+
* @param {string} key Message key.
|
|
33
|
+
* @returns {string|null} The English text, or null when the catalogue has no entry.
|
|
34
|
+
*/
|
|
35
|
+
export declare function defaultMessage(key: string): string | null;
|
|
36
|
+
/**
|
|
37
|
+
* The key a renamed message key replaced, which is still honoured for one major version.
|
|
38
|
+
* @param {string} key Current message key.
|
|
39
|
+
* @returns {string|null} The former key, or null when the key was never renamed.
|
|
40
|
+
*/
|
|
41
|
+
export declare function legacyMessageKey(key: string): string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Translates a key and interpolates arguments. The host translator answers first (then, for a
|
|
44
|
+
* renamed key, the translator again under its former name), then the default English catalogue;
|
|
45
|
+
* a key neither knows comes back unchanged.
|
|
22
46
|
* @param {string} key Translation key.
|
|
23
47
|
* @param {unknown[]|Record<string, unknown>|string|number} [args] Interpolation arguments.
|
|
24
48
|
* @returns {string}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The icon layer. Two renderers sit behind one `icon()` call:
|
|
3
3
|
*
|
|
4
|
-
* - **built-in** (default) — the inline SVG glyphs below, no network, no
|
|
4
|
+
* - **built-in** (default) — the inline SVG outline glyphs below (Lucide), no network, no
|
|
5
|
+
* stylesheet, no font. Applications can add their own, filled or outlined, with `registerIcons()`.
|
|
5
6
|
* - **Font Awesome** — `<i>` elements carrying Font Awesome classes, after an application opts in
|
|
6
7
|
* with `useFontAwesome()` or `loadFontAwesome(kit)`. Zx never loads a kit by itself.
|
|
7
8
|
*
|
|
@@ -40,28 +41,16 @@ export type IconOptions = {
|
|
|
40
41
|
*/
|
|
41
42
|
strict?: boolean;
|
|
42
43
|
};
|
|
44
|
+
export type IconPaint = 'fill' | 'stroke';
|
|
45
|
+
export type IconGlyph = [string, string] | [string, string, IconPaint];
|
|
43
46
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* @
|
|
49
|
-
* @property {string} [family] Font Awesome family for this icon only (`'classic'`, `'sharp'`, …).
|
|
50
|
-
* @property {boolean} [fixedWidth] Adds Font Awesome's `fa-fw` for column-aligned glyphs.
|
|
51
|
-
* @property {boolean} [strict=false] Throws `RangeError` on a name the bundled glyph set does not
|
|
52
|
-
* carry, instead of returning the placeholder. For call sites that can afford to fail — a test,
|
|
53
|
-
* a build-time check — rather than a screen rendering server data.
|
|
47
|
+
* The bundled glyph set: outline icons from Lucide (ISC; see the notice above), embedded as path
|
|
48
|
+
* data so the library carries no webfont, stylesheet, or package dependency. Every entry is
|
|
49
|
+
* `[viewBox, path, 'stroke']` in a 24-unit view box. Extend the set with `registerIcons()`; read
|
|
50
|
+
* every available name with `iconNames()`.
|
|
51
|
+
* @type {Readonly<Record<string, IconGlyph>>}
|
|
54
52
|
*/
|
|
55
|
-
|
|
56
|
-
* Icon glyphs from Font Awesome Free 6 (solid, plus `square` from regular), fontawesome.com,
|
|
57
|
-
* licensed CC BY 4.0 (https://fontawesome.com/license/free). Path data is embedded unmodified so
|
|
58
|
-
* the library carries no webfont, stylesheet, or package dependency. Each entry is
|
|
59
|
-
* `[viewBox, path]`; Font Awesome glyphs are filled (not stroked) and use per-glyph 512-unit view
|
|
60
|
-
* boxes — outlines such as `square` are a filled path with a counter-wound hole.
|
|
61
|
-
* Extend the set with `registerIcons()`; read every available name with `iconNames()`.
|
|
62
|
-
* @type {Readonly<Record<string, [string, string]>>}
|
|
63
|
-
*/
|
|
64
|
-
export declare const icons: Readonly<Record<string, [string, string]>>;
|
|
53
|
+
export declare const icons: Readonly<Record<string, IconGlyph>>;
|
|
65
54
|
export type IconConfig = {
|
|
66
55
|
/**
|
|
67
56
|
* Renderer used for bare icon names.
|
|
@@ -120,12 +109,21 @@ export declare function loadFontAwesome(options: string | (Partial<Omit<IconConf
|
|
|
120
109
|
activate?: boolean;
|
|
121
110
|
})): Promise<IconConfig>;
|
|
122
111
|
/**
|
|
123
|
-
* Adds inline SVG glyphs to the built-in set, or replaces existing ones.
|
|
124
|
-
*
|
|
125
|
-
*
|
|
112
|
+
* Adds inline SVG glyphs to the built-in set, or replaces existing ones.
|
|
113
|
+
*
|
|
114
|
+
* An entry is `[viewBox, path]` — a filled shape, the format Font Awesome path data comes in, and
|
|
115
|
+
* how it always rendered — or `[viewBox, path, 'stroke']` — an outline drawn with the same pen as
|
|
116
|
+
* the bundled set: `currentColor`, round caps and joins, and a stroke scaled to the view box, so a
|
|
117
|
+
* glyph from a 24-unit outline set such as Lucide renders exactly like a bundled one.
|
|
118
|
+
*
|
|
119
|
+
* registerIcons({ rocket: ['0 0 512 512', 'M…'] }); // filled
|
|
120
|
+
* registerIcons({ anchor: ['0 0 24 24', 'M12 6v16…', 'stroke'] }); // outline
|
|
121
|
+
* @param {Record<string, IconGlyph>} glyphs Glyphs keyed by icon name.
|
|
126
122
|
* @returns {void}
|
|
123
|
+
* @throws {TypeError} When an entry is neither a `[viewBox, path]` pair nor a
|
|
124
|
+
* `[viewBox, path, 'fill'|'stroke']` triple.
|
|
127
125
|
*/
|
|
128
|
-
export declare function registerIcons(glyphs: Record<string,
|
|
126
|
+
export declare function registerIcons(glyphs: Record<string, IconGlyph>): void;
|
|
129
127
|
/**
|
|
130
128
|
* Lists every inline SVG glyph name available, built-in and registered.
|
|
131
129
|
* @returns {string[]} Sorted icon names.
|
|
@@ -7,6 +7,12 @@ export type RovingOptions = {
|
|
|
7
7
|
* Whether navigation wraps at either end.
|
|
8
8
|
*/
|
|
9
9
|
wrap?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether ArrowLeft and ArrowRight swap meaning in a
|
|
12
|
+
* horizontal group. `'auto'` reads the container's computed `direction` on every key press, so
|
|
13
|
+
* a group inside `dir="rtl"` moves to the visually next item; `true`/`false` force it.
|
|
14
|
+
*/
|
|
15
|
+
rtl?: 'auto' | boolean;
|
|
10
16
|
};
|
|
11
17
|
export type FocusTrapController = {
|
|
12
18
|
/**
|
|
@@ -36,6 +42,9 @@ export type RovingController = {
|
|
|
36
42
|
* @typedef {Object} RovingOptions
|
|
37
43
|
* @property {'vertical'|'horizontal'} [orientation='vertical'] Arrow-key axis.
|
|
38
44
|
* @property {boolean} [wrap=true] Whether navigation wraps at either end.
|
|
45
|
+
* @property {'auto'|boolean} [rtl='auto'] Whether ArrowLeft and ArrowRight swap meaning in a
|
|
46
|
+
* horizontal group. `'auto'` reads the container's computed `direction` on every key press, so
|
|
47
|
+
* a group inside `dir="rtl"` moves to the visually next item; `true`/`false` force it.
|
|
39
48
|
*/
|
|
40
49
|
/**
|
|
41
50
|
* @typedef {Object} FocusTrapController
|
|
@@ -56,12 +65,74 @@ export type RovingController = {
|
|
|
56
65
|
export declare function focusTrap(container: Element): FocusTrapController;
|
|
57
66
|
/**
|
|
58
67
|
* Applies the ARIA roving-tabindex keyboard pattern to matching descendants.
|
|
68
|
+
*
|
|
69
|
+
* Editable items keep the keys they need, as the APG toolbar pattern asks: Home and End always
|
|
70
|
+
* stay with a text field, select, or contenteditable region, and so do the arrow keys — except
|
|
71
|
+
* that a text field whose caret already sits at the edge the arrow points past hands focus on to
|
|
72
|
+
* the neighbouring item, so a reader is never trapped in it. Under `dir="rtl"` the horizontal
|
|
73
|
+
* arrows follow the visual order.
|
|
74
|
+
*
|
|
75
|
+
* The group re-reads its items when children are added or removed and when an availability
|
|
76
|
+
* attribute (`hidden`, `disabled`, `aria-disabled`, `aria-hidden`) changes on an item or on an
|
|
77
|
+
* element inside the container that holds items — a `<fieldset disabled>` toggled around them; its
|
|
78
|
+
* own `tabindex` writes and unrelated attribute churn are not observed.
|
|
59
79
|
* @param {Element} container Event and query container.
|
|
60
80
|
* @param {string} itemSelector Selector for roving items.
|
|
61
81
|
* @param {RovingOptions} [options={}] Behavior options.
|
|
62
82
|
* @returns {RovingController}
|
|
63
83
|
*/
|
|
64
|
-
export declare function rovingTabindex(container: Element, itemSelector: string, { orientation, wrap }?: RovingOptions): RovingController;
|
|
84
|
+
export declare function rovingTabindex(container: Element, itemSelector: string, { orientation, wrap, rtl }?: RovingOptions): RovingController;
|
|
85
|
+
export type ItemFocusMemo = {
|
|
86
|
+
/**
|
|
87
|
+
* The item's key.
|
|
88
|
+
*/
|
|
89
|
+
key: unknown;
|
|
90
|
+
/**
|
|
91
|
+
* Whether the item element itself held focus.
|
|
92
|
+
*/
|
|
93
|
+
self: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Position of the focused control among the item's focusable controls.
|
|
96
|
+
*/
|
|
97
|
+
index: number;
|
|
98
|
+
/**
|
|
99
|
+
* Tag, data attributes, and name of the focused control, which
|
|
100
|
+
* identify its replacement after a rebuild.
|
|
101
|
+
*/
|
|
102
|
+
signature: string;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Where focus sat inside one keyed item of a collection, recorded before the collection re-renders.
|
|
106
|
+
* @typedef {Object} ItemFocusMemo
|
|
107
|
+
* @property {unknown} key The item's key.
|
|
108
|
+
* @property {boolean} self Whether the item element itself held focus.
|
|
109
|
+
* @property {number} index Position of the focused control among the item's focusable controls.
|
|
110
|
+
* @property {string} signature Tag, data attributes, and name of the focused control, which
|
|
111
|
+
* identify its replacement after a rebuild.
|
|
112
|
+
*/
|
|
113
|
+
/**
|
|
114
|
+
* Records which control of which keyed item holds focus, so a collection that rebuilds an item
|
|
115
|
+
* can put focus back on the equivalent control afterwards. Returns null when focus is elsewhere.
|
|
116
|
+
* @param {Element} root Collection root.
|
|
117
|
+
* @param {(element: Element) => ({key: unknown, element: Element}|null)} locate Finds the keyed
|
|
118
|
+
* item an element belongs to.
|
|
119
|
+
* @returns {ItemFocusMemo|null}
|
|
120
|
+
*/
|
|
121
|
+
export declare function captureItemFocus(root: Element, locate: (element: Element) => ({
|
|
122
|
+
key: unknown;
|
|
123
|
+
element: Element;
|
|
124
|
+
} | null)): ItemFocusMemo | null;
|
|
125
|
+
/**
|
|
126
|
+
* Puts focus back on the control a {@link captureItemFocus} memo describes, unless focus is still
|
|
127
|
+
* on a live element inside the collection (nothing was lost). The replacement is the control with
|
|
128
|
+
* the same signature, else the one at the same position, else the item's last control, else the
|
|
129
|
+
* item itself when it is focusable. Scrolling is suppressed: the reader did not move.
|
|
130
|
+
* @param {Element} root Collection root.
|
|
131
|
+
* @param {ItemFocusMemo|null} memo Recorded focus.
|
|
132
|
+
* @param {(key: unknown) => Element|null} resolve Finds the item element for a key after the update.
|
|
133
|
+
* @returns {boolean} Whether focus was moved.
|
|
134
|
+
*/
|
|
135
|
+
export declare function restoreItemFocus(root: Element, memo: ItemFocusMemo | null, resolve: (key: unknown) => Element | null): boolean;
|
|
65
136
|
/**
|
|
66
137
|
* Creates a 500 ms buffered, case-insensitive first-letter typeahead handler.
|
|
67
138
|
* @template T
|
|
@@ -70,3 +141,29 @@ export declare function rovingTabindex(container: Element, itemSelector: string,
|
|
|
70
141
|
* @returns {(event: KeyboardEvent|string) => void}
|
|
71
142
|
*/
|
|
72
143
|
export declare function typeahead<T>(getItems: () => T[], onMatch: (item: T, index: number) => void): (event: KeyboardEvent | string) => void;
|
|
144
|
+
/**
|
|
145
|
+
* Maps a key to a roving step, or null for a key the group does not handle.
|
|
146
|
+
* @param {string} key `KeyboardEvent.key`.
|
|
147
|
+
* @param {'vertical'|'horizontal'} orientation Arrow-key axis.
|
|
148
|
+
* @param {boolean} reversed Whether the horizontal arrows are swapped (right-to-left).
|
|
149
|
+
* @returns {'first'|'last'|'previous'|'next'|null}
|
|
150
|
+
*/
|
|
151
|
+
export declare function rovingStep(key: string, orientation: 'vertical' | 'horizontal', reversed?: boolean): 'first' | 'last' | 'previous' | 'next' | null;
|
|
152
|
+
/**
|
|
153
|
+
* Whether an element takes keyboard text input, so that arrow keys and Home/End move its caret
|
|
154
|
+
* or its value: a text-like `<input>`, `<textarea>`, `<select>`, or a contenteditable region.
|
|
155
|
+
* @param {Element|null} element Candidate, normally a key event's target.
|
|
156
|
+
* @returns {boolean}
|
|
157
|
+
*/
|
|
158
|
+
export declare function isEditableTarget(element: Element | null): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Whether a roving step may leave the event target. Non-editable targets always may. An editable
|
|
161
|
+
* one keeps Home/End, and keeps the arrows unless it is a single-line text field whose collapsed
|
|
162
|
+
* caret already sits at the edge the step points past: position 0 for `previous`, the end of the
|
|
163
|
+
* value for `next`. The steps are logical, so under right-to-left the caret check still matches
|
|
164
|
+
* the direction the caret would have moved.
|
|
165
|
+
* @param {Element|null} target Key event target.
|
|
166
|
+
* @param {'first'|'last'|'previous'|'next'} step Roving step.
|
|
167
|
+
* @returns {boolean}
|
|
168
|
+
*/
|
|
169
|
+
export declare function editableAllowsRoving(target: Element | null, step: 'first' | 'last' | 'previous' | 'next'): boolean;
|