datocms-react-ui 3.1.0-next.0 → 3.1.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/dist/Actions.d.ts +1 -0
  2. package/dist/Actions.js +4 -0
  3. package/dist/IconAvatar.d.ts +2 -0
  4. package/dist/IconAvatar.js +2 -0
  5. package/dist/ListDetail.js +2 -2
  6. package/dist/Pane.js +2 -1
  7. package/dist/SplitPane.js +2 -2
  8. package/dist/react-ui/src/Canvas.d.ts +2 -1
  9. package/dist/react-ui/src/Canvas.js +8 -6
  10. package/dist/react-ui/src/ContextInspector.js +2 -2
  11. package/dist/react-ui/src/messageText.js +1 -1
  12. package/dist/styles.css +330 -195
  13. package/dist/ui/icons/brands/gitlab.js +15 -0
  14. package/dist/ui/icons/custom/netlify.js +7 -29
  15. package/dist/ui/icons/custom/vercel.js +1 -4
  16. package/dist/ui/icons/index.js +206 -195
  17. package/dist/ui/icons/regular/command.js +16 -0
  18. package/dist/ui/icons/regular/keyboard.js +16 -0
  19. package/dist/ui/icons/regular/list-tree.js +2 -1
  20. package/dist/ui/icons/regular/list.js +2 -1
  21. package/dist/ui/icons/regular/memo.js +2 -1
  22. package/dist/ui/locales/en.js +10 -3
  23. package/dist/ui/src/BundledTexts.js +2 -2
  24. package/dist/ui/src/UiTextKey.d.ts +1 -1
  25. package/dist/ui/src/actions/Actions/ActionTooltip.js +24 -0
  26. package/dist/ui/src/actions/Actions/Shortcut.d.ts +23 -0
  27. package/dist/ui/src/actions/Actions/Shortcut.js +45 -0
  28. package/dist/ui/src/actions/Actions/index.d.ts +3 -0
  29. package/dist/ui/src/actions/Actions/index.js +3 -0
  30. package/dist/ui/src/actions/Actions/registry.d.ts +211 -0
  31. package/dist/ui/src/actions/Actions/registry.js +580 -0
  32. package/dist/ui/src/actions/Actions/shortcuts.d.ts +85 -0
  33. package/dist/ui/src/actions/Actions/shortcuts.js +284 -0
  34. package/dist/ui/src/actions/Button.d.ts +13 -12
  35. package/dist/ui/src/actions/Button.js +8 -7
  36. package/dist/ui/src/actions/Dropdown/DropdownContext.js +2 -1
  37. package/dist/ui/src/actions/Dropdown/Footer.js +1 -1
  38. package/dist/ui/src/actions/Dropdown/Menu.d.ts +2 -1
  39. package/dist/ui/src/actions/Dropdown/Menu.js +43 -37
  40. package/dist/ui/src/actions/Dropdown/MenuContent.js +22 -12
  41. package/dist/ui/src/actions/Dropdown/MenuParts.js +3 -3
  42. package/dist/ui/src/actions/Dropdown/Option.d.ts +20 -3
  43. package/dist/ui/src/actions/Dropdown/Option.js +48 -9
  44. package/dist/ui/src/actions/Dropdown/OptionAction.js +1 -1
  45. package/dist/ui/src/actions/Dropdown/Submenu.js +2 -2
  46. package/dist/ui/src/actions/Dropdown/index.d.ts +4 -1
  47. package/dist/ui/src/actions/Dropdown/index.js +6 -4
  48. package/dist/ui/src/actions/Dropdown/triggers/ButtonTrigger.d.ts +4 -4
  49. package/dist/ui/src/actions/Dropdown/triggers/ButtonTrigger.js +7 -6
  50. package/dist/ui/src/actions/Dropdown/triggers/PillTrigger.js +1 -1
  51. package/dist/ui/src/actions/Dropdown/triggers/TextualTrigger.js +1 -1
  52. package/dist/ui/src/actions/EditorToolbar/Button.js +2 -2
  53. package/dist/ui/src/actions/EditorToolbar/Buttons.js +2 -2
  54. package/dist/ui/src/actions/EditorToolbar/index.js +1 -1
  55. package/dist/ui/src/actions/MultipleSelectionActionBar.d.ts +20 -3
  56. package/dist/ui/src/actions/MultipleSelectionActionBar.js +25 -7
  57. package/dist/ui/src/actions/SplitButton/Caret.js +1 -1
  58. package/dist/ui/src/actions/SplitButton/index.js +1 -1
  59. package/dist/ui/src/actions/disabledReason.js +1 -1
  60. package/dist/ui/src/content/Avatar.d.ts +5 -3
  61. package/dist/ui/src/content/Avatar.js +4 -3
  62. package/dist/ui/src/content/CodeSnippet.js +1 -1
  63. package/dist/ui/src/content/CopyButton.js +1 -1
  64. package/dist/ui/src/content/CopyableId.d.ts +6 -1
  65. package/dist/ui/src/content/CopyableId.js +5 -2
  66. package/dist/ui/src/content/CopyableValue.js +2 -2
  67. package/dist/ui/src/content/FeedbackDot.js +1 -1
  68. package/dist/ui/src/content/IconAvatar.d.ts +42 -0
  69. package/dist/ui/src/content/IconAvatar.js +36 -0
  70. package/dist/ui/src/content/InitialsAvatar.js +1 -2
  71. package/dist/ui/src/content/Pill.js +3 -3
  72. package/dist/ui/src/content/SmartDate.js +1 -1
  73. package/dist/ui/src/content/UploadThreatTriangle.js +1 -1
  74. package/dist/ui/src/content/UsageMeter.d.ts +2 -1
  75. package/dist/ui/src/content/UsageMeter.js +3 -2
  76. package/dist/ui/src/content/ValidityTriangles.js +3 -3
  77. package/dist/ui/src/feedback/BlankSlate.js +2 -2
  78. package/dist/ui/src/feedback/Callout.js +2 -2
  79. package/dist/ui/src/feedback/ProgressBar.js +1 -1
  80. package/dist/ui/src/form/AutosizeInput.js +1 -1
  81. package/dist/ui/src/form/FieldHint.js +1 -1
  82. package/dist/ui/src/form/FieldWrapper.js +1 -1
  83. package/dist/ui/src/form/InputGroup.js +1 -1
  84. package/dist/ui/src/form/Label.js +2 -2
  85. package/dist/ui/src/form/PasswordInput.js +1 -1
  86. package/dist/ui/src/form/RadioGroupInput.js +1 -1
  87. package/dist/ui/src/form/SelectInput/SelectMenu.js +3 -3
  88. package/dist/ui/src/form/SelectInput/SelectMultiValueRemove.js +7 -0
  89. package/dist/ui/src/form/SelectInput/SelectOption.js +1 -1
  90. package/dist/ui/src/form/SelectInput/SortableMultiValue.js +1 -1
  91. package/dist/ui/src/form/StringInput.js +1 -1
  92. package/dist/ui/src/form/SwitchInput.d.ts +2 -0
  93. package/dist/ui/src/form/SwitchInput.js +4 -3
  94. package/dist/ui/src/form/SwitchList.js +1 -1
  95. package/dist/ui/src/form/TableList.js +2 -2
  96. package/dist/ui/src/form/TextareaInput.js +1 -1
  97. package/dist/ui/src/i18n.js +6 -6
  98. package/dist/ui/src/layout/ListOrOverview.js +3 -3
  99. package/dist/ui/src/layout/Page/Page.js +1 -1
  100. package/dist/ui/src/layout/Page/PageContent.js +1 -1
  101. package/dist/ui/src/layout/Page/PageGroup.js +2 -2
  102. package/dist/ui/src/layout/Page/PageSection.js +1 -1
  103. package/dist/ui/src/layout/Pane/ListFilter.js +6 -12
  104. package/dist/ui/src/layout/Pane/PaneHeader.js +3 -3
  105. package/dist/ui/src/layout/Pane/PaneRegion.d.ts +14 -0
  106. package/dist/ui/src/layout/Pane/PaneRegion.js +23 -0
  107. package/dist/ui/src/layout/Pane/index.d.ts +1 -0
  108. package/dist/ui/src/layout/Pane/index.js +36 -32
  109. package/dist/ui/src/layout/SidebarPanel.js +1 -1
  110. package/dist/ui/src/layout/SplitPane.d.ts +2 -0
  111. package/dist/ui/src/layout/SplitPane.js +79 -37
  112. package/dist/ui/src/layout/SplitView/SashActionButton.js +17 -9
  113. package/dist/ui/src/layout/SplitView/SplitView.js +1 -1
  114. package/dist/ui/src/layout/SplitView/SplitViewSash.js +2 -1
  115. package/dist/ui/src/layout/Toolbar/AddNewButton.d.ts +10 -6
  116. package/dist/ui/src/layout/Toolbar/AddNewButton.js +10 -23
  117. package/dist/ui/src/layout/Toolbar/Divider.d.ts +8 -0
  118. package/dist/ui/src/layout/Toolbar/Divider.js +16 -0
  119. package/dist/ui/src/layout/Toolbar/DotsDropdown.d.ts +8 -1
  120. package/dist/ui/src/layout/Toolbar/DotsDropdown.js +3 -2
  121. package/dist/ui/src/layout/Toolbar/Fill.js +1 -1
  122. package/dist/ui/src/layout/Toolbar/FilterInput.d.ts +7 -3
  123. package/dist/ui/src/layout/Toolbar/FilterInput.js +62 -49
  124. package/dist/ui/src/layout/Toolbar/FilterToggle.d.ts +6 -4
  125. package/dist/ui/src/layout/Toolbar/FilterToggle.js +42 -7
  126. package/dist/ui/src/layout/Toolbar/GoBack.d.ts +6 -1
  127. package/dist/ui/src/layout/Toolbar/GoBack.js +12 -5
  128. package/dist/ui/src/layout/Toolbar/Group.js +1 -1
  129. package/dist/ui/src/layout/Toolbar/Help.js +3 -3
  130. package/dist/ui/src/layout/Toolbar/Pagination.js +2 -2
  131. package/dist/ui/src/layout/Toolbar/PresetsTitle.js +3 -3
  132. package/dist/ui/src/layout/Toolbar/PrimaryButton.d.ts +3 -3
  133. package/dist/ui/src/layout/Toolbar/PrimaryButton.js +2 -2
  134. package/dist/ui/src/layout/Toolbar/Root.d.ts +6 -1
  135. package/dist/ui/src/layout/Toolbar/Root.js +13 -2
  136. package/dist/ui/src/layout/Toolbar/Search.d.ts +2 -1
  137. package/dist/ui/src/layout/Toolbar/Search.js +8 -3
  138. package/dist/ui/src/layout/Toolbar/context.js +2 -1
  139. package/dist/ui/src/layout/Toolbar/index.d.ts +5 -3
  140. package/dist/ui/src/layout/Toolbar/index.js +2 -0
  141. package/dist/ui/src/lists/CardList.d.ts +7 -2
  142. package/dist/ui/src/lists/CardList.js +7 -6
  143. package/dist/ui/src/lists/EmptySlot.js +2 -2
  144. package/dist/ui/src/lists/EntityRow.js +1 -1
  145. package/dist/ui/src/lists/InfoList.js +8 -3
  146. package/dist/ui/src/lists/InsertGap.js +4 -4
  147. package/dist/ui/src/lists/MediaCard.d.ts +10 -0
  148. package/dist/ui/src/lists/MediaCard.js +9 -4
  149. package/dist/ui/src/lists/RowList.js +2 -2
  150. package/dist/ui/src/lists/SettingsList.js +1 -1
  151. package/dist/ui/src/lists/Table/Body.js +1 -1
  152. package/dist/ui/src/lists/Table/Cell.js +1 -1
  153. package/dist/ui/src/lists/Table/ColumnsMenu.js +1 -1
  154. package/dist/ui/src/lists/Table/Header.js +8 -10
  155. package/dist/ui/src/lists/Table/HeaderCell.js +2 -2
  156. package/dist/ui/src/lists/Table/Row.d.ts +7 -1
  157. package/dist/ui/src/lists/Table/Row.js +6 -2
  158. package/dist/ui/src/lists/Table/Table.js +1 -1
  159. package/dist/ui/src/lists/Table/TreeToggle.js +1 -1
  160. package/dist/ui/src/lists/Table/index.d.ts +1 -1
  161. package/dist/ui/src/lists/Table/layout.d.ts +3 -2
  162. package/dist/ui/src/lists/Table/layout.js +26 -13
  163. package/dist/ui/src/lists/dnd/DragHandle.js +1 -1
  164. package/dist/ui/src/lists/dnd/DropIndicator.js +1 -1
  165. package/dist/ui/src/lists/dnd/SortableList.js +2 -2
  166. package/dist/ui/src/lists/dnd/tree/SortableTree.js +1 -1
  167. package/dist/ui/src/navigation/Chevron.js +2 -2
  168. package/dist/ui/src/navigation/SegmentedControl.d.ts +23 -4
  169. package/dist/ui/src/navigation/SegmentedControl.js +23 -5
  170. package/dist/ui/src/navigation/SettingsMenu.js +3 -3
  171. package/dist/ui/src/navigation/SidebarTree/SidebarTreeNode.js +3 -3
  172. package/dist/ui/src/navigation/SidebarTree/SidebarTreeNodeActions.js +1 -1
  173. package/dist/ui/src/navigation/Tabs.js +1 -1
  174. package/dist/ui/src/overlays/FullscreenModal.js +48 -53
  175. package/dist/ui/src/overlays/HoverCard.js +4 -4
  176. package/dist/ui/src/overlays/Modal.d.ts +7 -0
  177. package/dist/ui/src/overlays/Modal.js +53 -55
  178. package/dist/ui/src/overlays/Popover.d.ts +6 -3
  179. package/dist/ui/src/overlays/Popover.js +13 -8
  180. package/dist/ui/src/overlays/Portal.js +1 -1
  181. package/dist/ui/src/overlays/Tooltip.d.ts +6 -3
  182. package/dist/ui/src/overlays/Tooltip.js +29 -13
  183. package/dist/ui/src/overlays/useModalClose.js +17 -12
  184. package/dist/ui/src/patterns/ListDetail/Page.d.ts +9 -0
  185. package/dist/ui/src/patterns/ListDetail/Page.js +33 -26
  186. package/dist/ui/src/patterns/ListDetail/Panel.js +4 -2
  187. package/dist/ui/src/patterns/ListDetail/Split.d.ts +5 -0
  188. package/dist/ui/src/patterns/ListDetail/Split.js +75 -56
  189. package/dist/ui/src/patterns/ListDetail/index.d.ts +2 -2
  190. package/dist/ui/src/patterns/ListDetail/index.js +2 -2
  191. package/dist/ui/src/patterns/ListFormPage.js +2 -2
  192. package/dist/ui/src/semantic/Main.d.ts +4 -1
  193. package/dist/ui/src/semantic/Main.js +53 -3
  194. package/dist/ui/src/semantic/NavigationFocusProvider.js +9 -0
  195. package/package.json +1 -1
  196. package/dist/HotKey.d.ts +0 -1
  197. package/dist/HotKey.js +0 -2
  198. package/dist/ui/src/actions/HotKey.d.ts +0 -98
  199. package/dist/ui/src/actions/HotKey.js +0 -270
  200. package/dist/ui/src/actions/hotKeyContext.d.ts +0 -32
  201. package/dist/ui/src/actions/hotKeyContext.js +0 -15
@@ -0,0 +1,284 @@
1
+ //#region ../ui/src/actions/Actions/shortcuts.ts
2
+ var LETTERS = [
3
+ "a",
4
+ "b",
5
+ "c",
6
+ "d",
7
+ "e",
8
+ "f",
9
+ "g",
10
+ "h",
11
+ "i",
12
+ "j",
13
+ "k",
14
+ "l",
15
+ "m",
16
+ "n",
17
+ "o",
18
+ "p",
19
+ "q",
20
+ "r",
21
+ "s",
22
+ "t",
23
+ "u",
24
+ "v",
25
+ "w",
26
+ "x",
27
+ "y",
28
+ "z"
29
+ ];
30
+ var DIGITS = [
31
+ "0",
32
+ "1",
33
+ "2",
34
+ "3",
35
+ "4",
36
+ "5",
37
+ "6",
38
+ "7",
39
+ "8",
40
+ "9"
41
+ ];
42
+ var FUNCTION_KEYS = [
43
+ "f1",
44
+ "f2",
45
+ "f3",
46
+ "f4",
47
+ "f5",
48
+ "f6",
49
+ "f7",
50
+ "f8",
51
+ "f9",
52
+ "f10",
53
+ "f11",
54
+ "f12"
55
+ ];
56
+ var SPECIAL_CODES = {
57
+ enter: ["Enter", "NumpadEnter"],
58
+ escape: ["Escape"],
59
+ space: ["Space"],
60
+ tab: ["Tab"],
61
+ backspace: ["Backspace"],
62
+ delete: ["Delete"],
63
+ arrowup: ["ArrowUp"],
64
+ arrowdown: ["ArrowDown"],
65
+ arrowleft: ["ArrowLeft"],
66
+ arrowright: ["ArrowRight"],
67
+ home: ["Home"],
68
+ end: ["End"],
69
+ pageup: ["PageUp"],
70
+ pagedown: ["PageDown"],
71
+ "/": ["Slash"],
72
+ ".": ["Period"],
73
+ ",": ["Comma"],
74
+ ";": ["Semicolon"],
75
+ "'": ["Quote"],
76
+ "[": ["BracketLeft"],
77
+ "]": ["BracketRight"],
78
+ "\\": ["Backslash"],
79
+ "-": ["Minus"],
80
+ "=": ["Equal"],
81
+ "`": ["Backquote"]
82
+ };
83
+ function isLetter(key) {
84
+ return LETTERS.includes(key);
85
+ }
86
+ function isNamedKey(key) {
87
+ return FUNCTION_KEYS.includes(key) || /^[a-z]{2,}$/.test(key);
88
+ }
89
+ /** A character from Space to `~`: the letters, the digits and the signs */
90
+ function isAsciiCharacter(value) {
91
+ return value.length === 1 && value >= " " && value <= "~";
92
+ }
93
+ function codesOf(key) {
94
+ if (isLetter(key)) return [`Key${key.toUpperCase()}`];
95
+ if (DIGITS.includes(key)) return [`Digit${key}`];
96
+ if (FUNCTION_KEYS.includes(key)) return [key.toUpperCase()];
97
+ return SPECIAL_CODES[key] ?? [];
98
+ }
99
+ function isKnownKey(key) {
100
+ return key === "?" || codesOf(key).length > 0;
101
+ }
102
+ function isSequence(shortcut) {
103
+ return Array.isArray(shortcut.key);
104
+ }
105
+ function toList(shortcut) {
106
+ if (!shortcut) return [];
107
+ return Array.isArray(shortcut) ? shortcut : [shortcut];
108
+ }
109
+ /**
110
+ * The reason why the registry refuses a shortcut, or undefined. The browser
111
+ * does not let a page cancel some keys on some systems, thus they never
112
+ * reach the page.
113
+ */
114
+ function shortcutProblem(shortcut) {
115
+ if (isSequence(shortcut)) {
116
+ if (shortcut.key.length !== 2) return "a sequence has exactly two keys";
117
+ if (shortcut.mod || shortcut.shift || shortcut.alt) return "a sequence has no modifiers";
118
+ if (shortcut.runWithInputFocus) return "a sequence does not work in a text field";
119
+ const unknown = shortcut.key.find((key) => !isKnownKey(key));
120
+ return unknown === void 0 ? void 0 : `"${unknown}" is not a key`;
121
+ }
122
+ const { key, mod, shift, alt, runWithInputFocus } = shortcut;
123
+ if (!isKnownKey(key)) return `"${key}" is not a key`;
124
+ if (runWithInputFocus && !mod) return "a shortcut with runWithInputFocus needs mod";
125
+ if (mod && !alt && !shift && [
126
+ "n",
127
+ "t",
128
+ "w"
129
+ ].includes(key)) return "the browser keeps mod+N, mod+T and mod+W";
130
+ if (mod && !alt && shift && ["n", "t"].includes(key)) return "the browser keeps mod+Shift+N and mod+Shift+T";
131
+ if (alt && !mod && !shift && isLetter(key)) return "Alt+letter opens the menu bar on Windows";
132
+ }
133
+ var KEY_ALIASES = {
134
+ esc: "escape",
135
+ return: "enter",
136
+ up: "arrowup",
137
+ down: "arrowdown",
138
+ left: "arrowleft",
139
+ right: "arrowright",
140
+ del: "delete"
141
+ };
142
+ /**
143
+ * The keys of a string in the format of `is-hotkey` ("mod+shift+s"), or
144
+ * undefined when the string has a key that a shortcut does not know. The
145
+ * text editors give their keys in this format.
146
+ */
147
+ function parseShortcut(hotKey) {
148
+ const parts = hotKey.toLowerCase().split("+");
149
+ const last = parts.pop() ?? "";
150
+ const key = KEY_ALIASES[last] ?? last;
151
+ if (!isKnownKey(key)) return void 0;
152
+ const shortcut = { key };
153
+ for (const part of parts) if ([
154
+ "mod",
155
+ "cmd",
156
+ "command",
157
+ "meta",
158
+ "ctrl",
159
+ "control"
160
+ ].includes(part)) shortcut.mod = true;
161
+ else if (part === "shift") shortcut.shift = true;
162
+ else if ([
163
+ "alt",
164
+ "option",
165
+ "opt"
166
+ ].includes(part)) shortcut.alt = true;
167
+ else return;
168
+ return shortcut;
169
+ }
170
+ function strokeOf(event, mac) {
171
+ return {
172
+ code: event.code,
173
+ key: event.key,
174
+ mod: mac ? event.metaKey : event.ctrlKey,
175
+ other: mac ? event.ctrlKey : event.metaKey,
176
+ shift: event.shiftKey,
177
+ alt: event.altKey
178
+ };
179
+ }
180
+ var MODIFIER_CODES = /^(Shift|Control|Alt|Meta|OS)(Left|Right)?$|^CapsLock$/;
181
+ function isModifierOnly(stroke) {
182
+ return MODIFIER_CODES.test(stroke.code);
183
+ }
184
+ /** The stroke is a key with no modifier: it can start a sequence */
185
+ function isPlain(stroke) {
186
+ return !stroke.mod && !stroke.other && !stroke.alt && !stroke.shift;
187
+ }
188
+ function keyMatches(key, modifiers, stroke) {
189
+ if (stroke.other || stroke.mod !== Boolean(modifiers.mod)) return false;
190
+ if (stroke.alt !== Boolean(modifiers.alt)) return false;
191
+ if (key === "?") return stroke.key === "?";
192
+ if (matchesCharacter(key, modifiers, stroke)) {
193
+ const character = stroke.key.toLowerCase();
194
+ return isLetter(key) ? character === key && stroke.shift === Boolean(modifiers.shift) : character === key;
195
+ }
196
+ if (stroke.shift !== Boolean(modifiers.shift)) return false;
197
+ return codesOf(key).includes(stroke.code);
198
+ }
199
+ /**
200
+ * The shortcut compares the character of the stroke, not the physical key.
201
+ * We do not compare the physical key when the layout types an ASCII
202
+ * character, because on an Italian keyboard Cmd + "-" is at the place of
203
+ * the US "/", and Cmd + "/" then takes the zoom out of the browser.
204
+ */
205
+ function matchesCharacter(key, modifiers, stroke) {
206
+ if (isNamedKey(key) || !isAsciiCharacter(stroke.key)) return false;
207
+ if (stroke.alt) return false;
208
+ return isLetter(key) || !modifiers.shift;
209
+ }
210
+ /** The shortcut matches the last stroke, or the last two for a sequence */
211
+ function shortcutMatches(shortcut, stroke, previous) {
212
+ if (isSequence(shortcut)) return previous !== void 0 && keyMatches(shortcut.key[0], {}, previous) && keyMatches(shortcut.key[1], {}, stroke);
213
+ return keyMatches(shortcut.key, shortcut, stroke);
214
+ }
215
+ /** The stroke is the first key of the sequence */
216
+ function sequenceStartsWith(shortcut, stroke) {
217
+ return isSequence(shortcut) && keyMatches(shortcut.key[0], {}, stroke);
218
+ }
219
+ function isMac() {
220
+ return typeof window !== "undefined" && /Mac|iPod|iPhone|iPad/.test(window.navigator.platform);
221
+ }
222
+ var KEY_LABELS = {
223
+ enter: "↵",
224
+ escape: "Esc",
225
+ space: "Space",
226
+ tab: "Tab",
227
+ backspace: "⌫",
228
+ delete: "Del",
229
+ arrowup: "↑",
230
+ arrowdown: "↓",
231
+ arrowleft: "←",
232
+ arrowright: "→",
233
+ home: "Home",
234
+ end: "End",
235
+ pageup: "PgUp",
236
+ pagedown: "PgDn"
237
+ };
238
+ var SPOKEN_KEYS = {
239
+ enter: "Enter",
240
+ escape: "Escape",
241
+ backspace: "Backspace",
242
+ delete: "Delete",
243
+ arrowup: "Up Arrow",
244
+ arrowdown: "Down Arrow",
245
+ arrowleft: "Left Arrow",
246
+ arrowright: "Right Arrow",
247
+ pageup: "Page Up",
248
+ pagedown: "Page Down"
249
+ };
250
+ function keyLabel(key) {
251
+ const visible = KEY_LABELS[key] ?? key.toUpperCase();
252
+ return {
253
+ visible,
254
+ spoken: SPOKEN_KEYS[key] ?? visible
255
+ };
256
+ }
257
+ /**
258
+ * The keys of each stroke of a shortcut, in the order of the system:
259
+ * ⌥ ⇧ ⌘ on a Mac, Ctrl Alt Shift elsewhere.
260
+ */
261
+ function strokeLabels(shortcut, mac) {
262
+ if (isSequence(shortcut)) return shortcut.key.map((key) => [keyLabel(key)]);
263
+ const { key, mod, shift, alt } = shortcut;
264
+ const labels = [];
265
+ const add = (on, visible, spoken) => {
266
+ if (on) labels.push({
267
+ visible,
268
+ spoken
269
+ });
270
+ };
271
+ if (mac) {
272
+ add(alt, "⌥", "Option");
273
+ add(shift, "⇧", "Shift");
274
+ add(mod, "⌘", "Command");
275
+ } else {
276
+ add(mod, "Ctrl", "Ctrl");
277
+ add(alt, "Alt", "Alt");
278
+ add(shift, "Shift", "Shift");
279
+ }
280
+ labels.push(keyLabel(key));
281
+ return [labels];
282
+ }
283
+ //#endregion
284
+ export { isMac, isModifierOnly, isPlain, isSequence, parseShortcut, sequenceStartsWith, shortcutMatches, shortcutProblem, strokeLabels, strokeOf, toList };
@@ -32,17 +32,18 @@ type WithLabel = {
32
32
  iconOnly?: false;
33
33
  /** Content after the label (for example a "PRO" pill) */
34
34
  trailing?: ReactNode;
35
- tooltip?: HotKeyTooltipOptions;
35
+ tooltip?: ActionTooltipOptions;
36
36
  };
37
37
  /**
38
- * The keys of the HotKeyListener around the button, in the tooltip. The
39
- * text is the label of an icon-only button, or the description of the
40
- * listener for a button with a label. When there is no listener, or it is
41
- * disabled, the tooltip has no keys: an icon-only button shows its label,
42
- * and a button with a label shows no tooltip.
38
+ * The name and the keys of an action of the registry (`ui/Actions`), in
39
+ * the tooltip. An icon-only button shows its label in place of the name.
40
+ * When the action has no keys or does not exist, the tooltip has no keys:
41
+ * an icon-only button shows its label, and a button with a label shows no
42
+ * tooltip.
43
43
  */
44
- export type HotKeyTooltipOptions = {
45
- hotKey: true;
44
+ export type ActionTooltipOptions = {
45
+ /** The id of the action */
46
+ action: string;
46
47
  /**
47
48
  * The tooltip goes below when there is no space above it.
48
49
  * @default "top"
@@ -58,8 +59,8 @@ type TooltipOptions =
58
59
  content?: Message;
59
60
  long?: boolean;
60
61
  placement?: Placement;
61
- hotKey?: never;
62
- } | HotKeyTooltipOptions;
62
+ action?: never;
63
+ } | ActionTooltipOptions;
63
64
  /**
64
65
  * Only the icon. The label is the accessible name of the button, and a
65
66
  * tooltip shows it.
@@ -183,8 +184,8 @@ export declare function buttonClassName({ tone, size, iconOnly, expand, }: {
183
184
  *
184
185
  * A button with a label can be in a Tooltip: the button takes its ref and
185
186
  * its event props. A button with only the icon has its own tooltip: do not
186
- * put it in a Tooltip. For the keys of a HotKeyListener, give
187
- * "tooltip={{ hotKey: true }}" (not a HotKeyTooltip).
187
+ * put it in a Tooltip. For the name and the keys of an action, give
188
+ * "tooltip={{ action: id }}".
188
189
  */
189
190
  declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLElement>>;
190
191
  export default Button;
@@ -2,13 +2,13 @@ import { isHtmlMessage, isIntlMessage } from "../Message.js";
2
2
  import { useTranslation } from "../i18n.js";
3
3
  import Spinner_default from "../feedback/Spinner.js";
4
4
  import Link from "../navigation/Link.js";
5
- import Tooltip from "../overlays/Tooltip.js";
6
5
  import RawButton from "../semantic/RawButton.js";
6
+ import { ActionTooltip } from "./Actions/ActionTooltip.js";
7
7
  import { DisabledReasonTooltip, disabledReasonOf } from "./disabledReason.js";
8
- import { HotKeyTooltip } from "./HotKey.js";
8
+ import Tooltip from "../overlays/Tooltip.js";
9
9
  import React, { useContext, useEffect, useRef, useState } from "react";
10
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
10
  import classNames from "classnames";
11
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
12
12
  //#region ../ui/src/actions/Button.tsx
13
13
  /**
14
14
  * The size of the buttons of the place, when a button does not give one:
@@ -56,8 +56,8 @@ function buttonClassName({ tone, size, iconOnly, expand }) {
56
56
  *
57
57
  * A button with a label can be in a Tooltip: the button takes its ref and
58
58
  * its event props. A button with only the icon has its own tooltip: do not
59
- * put it in a Tooltip. For the keys of a HotKeyListener, give
60
- * "tooltip={{ hotKey: true }}" (not a HotKeyTooltip).
59
+ * put it in a Tooltip. For the name and the keys of an action, give
60
+ * "tooltip={{ action: id }}".
61
61
  */
62
62
  var Button = React.forwardRef(function Button({ tone = "soft", size, expand, disabled, busy: outsideBusy, pressed, className, label, icon: Icon, iconOnly, trailing, tooltip, onClick, to, newTab, href, submit, ...rest }, ref) {
63
63
  const placeSize = useButtonSize();
@@ -98,7 +98,7 @@ var Button = React.forwardRef(function Button({ tone = "soft", size, expand, dis
98
98
  inline: true,
99
99
  label: false
100
100
  }) : Icon && /* @__PURE__ */ jsx(Icon, {});
101
- const content = iconOnly ? leading : /* @__PURE__ */ jsxs(Fragment, { children: [
101
+ const content = iconOnly ? leading : /* @__PURE__ */ jsxs(Fragment$1, { children: [
102
102
  leading,
103
103
  /* @__PURE__ */ jsx("span", { children: tc(label) }),
104
104
  trailing
@@ -142,7 +142,8 @@ var Button = React.forwardRef(function Button({ tone = "soft", size, expand, dis
142
142
  placement: isTooltipOptions(tooltip) ? tooltip.placement : void 0,
143
143
  children: element
144
144
  });
145
- if (isTooltipOptions(tooltip) && tooltip.hotKey) return /* @__PURE__ */ jsx(HotKeyTooltip, {
145
+ if (isTooltipOptions(tooltip) && tooltip.action !== void 0) return /* @__PURE__ */ jsx(ActionTooltip, {
146
+ action: tooltip.action,
146
147
  placement: tooltip.placement,
147
148
  label: iconOnlyLabel,
148
149
  children: element
@@ -5,7 +5,8 @@ var DropdownContext = createContext({
5
5
  setCloseOnClickOutside: (_value) => {},
6
6
  isClosing: false,
7
7
  triggerId: void 0,
8
- menuId: void 0
8
+ menuId: void 0,
9
+ rootRef: { current: null }
9
10
  });
10
11
  //#endregion
11
12
  export { DropdownContext as default };
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
- import { jsx } from "react/jsx-runtime";
3
2
  import classNames from "classnames";
3
+ import { jsx } from "react/jsx-runtime";
4
4
  //#region ../ui/src/actions/Dropdown/Footer.tsx
5
5
  /** The bottom area of a menu. It stays visible when the options scroll. */
6
6
  var Footer = ({ variant = "buttons", children }) => {
@@ -39,7 +39,8 @@ export type MenuProps = {
39
39
  };
40
40
  /**
41
41
  * The floating menu of a Dropdown. It closes with Escape, Tab and a click
42
- * out of it. The arrow keys move the highlight, and Enter picks the option.
42
+ * out of it. While it is open, the actions of the page and of the regions
43
+ * are off. The arrow keys move the highlight, and Enter picks the option.
43
44
  * On a small screen, the menu is a sheet at the bottom of the screen.
44
45
  */
45
46
  declare const Menu: React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,7 +1,8 @@
1
+ import { ActionLayer } from "../Actions/registry.js";
1
2
  import { useTranslation } from "../../i18n.js";
3
+ import { useIsMenuSheet } from "./MenuSheet.js";
2
4
  import NewZIndex from "../../overlays/NewZIndex.js";
3
5
  import Portal from "../../overlays/Portal.js";
4
- import { useIsMenuSheet } from "./MenuSheet.js";
5
6
  import DropdownContext from "./DropdownContext.js";
6
7
  import { MenuContainer, MenuPanel } from "./MenuParts.js";
7
8
  import { useTriggerLang } from "./useTriggerLang.js";
@@ -9,8 +10,8 @@ import MenuContent from "./MenuContent.js";
9
10
  import Option from "./Option.js";
10
11
  import { placementStyle } from "./placementStyle.js";
11
12
  import React, { useContext } from "react";
12
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
13
  import classNames from "classnames";
14
+ import { jsx, jsxs } from "react/jsx-runtime";
14
15
  import mergeRefs from "@react-hook/merged-ref";
15
16
  import { autoUpdate, flip, offset, size, useFloating } from "@floating-ui/react-dom";
16
17
  import "intersection-observer";
@@ -35,7 +36,8 @@ var MenuDesktopContainer = React.forwardRef(({ children, style, className, onCli
35
36
  });
36
37
  /**
37
38
  * The floating menu of a Dropdown. It closes with Escape, Tab and a click
38
- * out of it. The arrow keys move the highlight, and Enter picks the option.
39
+ * out of it. While it is open, the actions of the page and of the regions
40
+ * are off. The arrow keys move the highlight, and Enter picks the option.
39
41
  * On a small screen, the menu is a sheet at the bottom of the screen.
40
42
  */
41
43
  var Menu = React.forwardRef(({ children, placement = "bottom-start", noOverflowHidden, minWidth, optionPaddingY, contextualSearch = "auto", offset: offsetOptions = { mainAxis: 4 } }, ref) => {
@@ -59,41 +61,45 @@ var Menu = React.forwardRef(({ children, placement = "bottom-start", noOverflowH
59
61
  ]
60
62
  });
61
63
  const { style: placementVars, ...placementAttributes } = placementStyle(finalPlacement);
62
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
63
- ref: refs.setReference,
64
- className: "Dropdown__spacer"
65
- }), /* @__PURE__ */ jsx(Wrapper, {
66
- ref: ref ? mergeRefs(ref, refs.setFloating) : refs.setFloating,
67
- style: {
68
- ...floatingStyles,
69
- ...placementVars
70
- },
71
- className: classNames(isClosing && "is-closing"),
72
- onClickOutside: () => {
73
- closeMenu();
74
- },
75
- ...placementAttributes,
76
- children: /* @__PURE__ */ jsxs("div", {
77
- lang: detectedLocale,
78
- className: classNames(isMobile && "Dropdown__menu__mobile-content"),
79
- onClick: (e) => {
80
- e.stopPropagation();
64
+ return /* @__PURE__ */ jsxs(ActionLayer, {
65
+ kind: "popover",
66
+ active: !isClosing,
67
+ children: [/* @__PURE__ */ jsx("div", {
68
+ ref: refs.setReference,
69
+ className: "Dropdown__spacer"
70
+ }), /* @__PURE__ */ jsx(Wrapper, {
71
+ ref: ref ? mergeRefs(ref, refs.setFloating) : refs.setFloating,
72
+ style: {
73
+ ...floatingStyles,
74
+ ...placementVars
75
+ },
76
+ className: classNames(isClosing && "is-closing"),
77
+ onClickOutside: () => {
78
+ closeMenu();
81
79
  },
82
- children: [/* @__PURE__ */ jsx(MenuContent, {
83
- isRoot: true,
84
- title: isMobile ? { id: "dropdown.selectOption" } : void 0,
85
- noOverflowHidden,
86
- contextualSearch,
87
- minWidth: isMobile ? void 0 : minWidth,
88
- optionPaddingY,
89
- children
90
- }), isMobile ? /* @__PURE__ */ jsx(MenuPanel, { children: /* @__PURE__ */ jsx(Option, {
91
- closeMenuOnClick: true,
92
- onPick: () => {},
93
- children: /* @__PURE__ */ jsx("span", { children: t("modal.close") })
94
- }) }) : null]
95
- })
96
- })] });
80
+ ...placementAttributes,
81
+ children: /* @__PURE__ */ jsxs("div", {
82
+ lang: detectedLocale,
83
+ className: classNames(isMobile && "Dropdown__menu__mobile-content"),
84
+ onClick: (e) => {
85
+ e.stopPropagation();
86
+ },
87
+ children: [/* @__PURE__ */ jsx(MenuContent, {
88
+ isRoot: true,
89
+ title: isMobile ? { id: "dropdown.selectOption" } : void 0,
90
+ noOverflowHidden,
91
+ contextualSearch,
92
+ minWidth: isMobile ? void 0 : minWidth,
93
+ optionPaddingY,
94
+ children
95
+ }), isMobile ? /* @__PURE__ */ jsx(MenuPanel, { children: /* @__PURE__ */ jsx(Option, {
96
+ closeMenuOnClick: true,
97
+ onPick: () => {},
98
+ children: /* @__PURE__ */ jsx("span", { children: t("modal.close") })
99
+ }) }) : null]
100
+ })
101
+ })]
102
+ });
97
103
  });
98
104
  //#endregion
99
105
  export { Menu as default };
@@ -1,14 +1,22 @@
1
- import { useTranslation } from "../../i18n.js";
2
1
  import { Generic } from "../../../icons/index.js";
2
+ import { useTranslation } from "../../i18n.js";
3
3
  import DropdownContext from "./DropdownContext.js";
4
4
  import { MenuPanel } from "./MenuParts.js";
5
5
  import MenuContext from "./MenuContext.js";
6
6
  import { useTriggerLang } from "./useTriggerLang.js";
7
- import { useCallback, useContext, useEffect, useRef, useState } from "react";
7
+ import { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
8
+ import classNames from "classnames";
8
9
  import { jsx, jsxs } from "react/jsx-runtime";
9
10
  import { isHotkey } from "is-hotkey-esm";
10
- import classNames from "classnames";
11
11
  //#region ../ui/src/actions/Dropdown/MenuContent.tsx
12
+ function highlightOption(menu, option) {
13
+ option.classList.add("is-selected");
14
+ menu.setAttribute("aria-activedescendant", option.id);
15
+ option.scrollIntoView({
16
+ behavior: "auto",
17
+ block: "nearest"
18
+ });
19
+ }
12
20
  function MenuContent({ children, noOverflowHidden, contextualSearch = "auto", minWidth, optionPaddingY, isRoot = false, title }) {
13
21
  const { t, tm, tc } = useTranslation();
14
22
  const { closeMenu, triggerId, menuId } = useContext(DropdownContext);
@@ -43,6 +51,15 @@ function MenuContent({ children, noOverflowHidden, contextualSearch = "auto", mi
43
51
  const lang = useTriggerLang();
44
52
  const showSearch = contextualSearch === "auto" && options.length > 5 || contextualSearch === true || typeof contextualSearch === "object";
45
53
  const searchPlaceholder = typeof contextualSearch === "object" ? contextualSearch.placeholder : void 0;
54
+ const openedByKeyRef = useRef(false);
55
+ useLayoutEffect(() => {
56
+ openedByKeyRef.current = Boolean(triggerId && document.getElementById(triggerId)?.matches(":focus-visible"));
57
+ }, [triggerId]);
58
+ useEffect(() => {
59
+ const focusTarget = showSearch ? searchInputRef.current : menuRef.current;
60
+ const first = menuRef.current?.querySelector(".Dropdown__menu__option:not(.is-disabled)");
61
+ if (isRoot && openedByKeyRef.current && first && focusTarget) highlightOption(focusTarget, first);
62
+ }, [isRoot, showSearch]);
46
63
  useEffect(() => {
47
64
  if (showSearch) searchInputRef.current?.focus();
48
65
  else if (isRoot) menuRef.current?.focus();
@@ -66,16 +83,9 @@ function MenuContent({ children, noOverflowHidden, contextualSearch = "auto", mi
66
83
  if (index !== -1) nextOption = elements[index + delta < 0 ? elements.length - 1 : (index + delta) % elements.length];
67
84
  else nextOption = elements[0];
68
85
  selectedOption?.classList.remove("is-selected");
69
- if (nextOption) {
70
- nextOption.classList.add("is-selected");
71
- event.currentTarget.setAttribute("aria-activedescendant", nextOption.id);
72
- nextOption.scrollIntoView({
73
- behavior: "auto",
74
- block: "nearest"
75
- });
76
- }
86
+ if (nextOption) highlightOption(event.currentTarget, nextOption);
77
87
  }
78
- if (isHotkey("enter", event.nativeEvent)) {
88
+ if (isHotkey("enter", event.nativeEvent) || isHotkey("space", event.nativeEvent) && event.target === menuRef.current) {
79
89
  event.preventDefault();
80
90
  event.stopPropagation();
81
91
  if (!contentRef.current) return;
@@ -1,10 +1,10 @@
1
+ import { UI } from "../../../icons/index.js";
1
2
  import { useTranslation } from "../../i18n.js";
2
3
  import Link from "../../navigation/Link.js";
3
4
  import RawButton from "../../semantic/RawButton.js";
4
- import { UI } from "../../../icons/index.js";
5
5
  import React from "react";
6
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
6
  import classNames from "classnames";
7
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
8
  //#region ../ui/src/actions/Dropdown/MenuParts.tsx
9
9
  var MenuContainer = React.memo(React.forwardRef(function MenuContainer({ className, ...rest }, ref) {
10
10
  return /* @__PURE__ */ jsx("div", {
@@ -37,7 +37,7 @@ var MenuEmpty = React.memo(function MenuEmpty({ children }) {
37
37
  });
38
38
  });
39
39
  var MenuItem = React.memo(React.forwardRef(function MenuItem({ selected, active, clickable, icon, children, before, after, contentRef, contentProps, link, className, ...rest }, ref) {
40
- const content = /* @__PURE__ */ jsxs(Fragment, { children: [icon, typeof children === "string" ? /* @__PURE__ */ jsx("span", { children }) : children] });
40
+ const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [icon, typeof children === "string" ? /* @__PURE__ */ jsx("span", { children }) : children] });
41
41
  return /* @__PURE__ */ jsxs("div", {
42
42
  ...rest,
43
43
  ref,
@@ -16,6 +16,20 @@ type PickAction = {
16
16
  to?: never;
17
17
  href?: never;
18
18
  newTab?: never;
19
+ action?: never;
20
+ };
21
+ /**
22
+ * Runs an action of the registry (`ui/Actions`). The keys of the action
23
+ * show at the end of the option. The option is disabled while the action
24
+ * gives a reason, or when the action does not exist now.
25
+ */
26
+ type RegistryAction = {
27
+ /** The id of the action */
28
+ action: string;
29
+ onPick?: never;
30
+ to?: never;
31
+ href?: never;
32
+ newTab?: never;
19
33
  };
20
34
  /**
21
35
  * A link to a page of the app. When the page is open, the option gets
@@ -28,6 +42,7 @@ type LinkAction = {
28
42
  newTab?: boolean;
29
43
  onPick?: never;
30
44
  href?: never;
45
+ action?: never;
31
46
  };
32
47
  /** A link to a page out of the app */
33
48
  type ExternalLinkAction = {
@@ -37,6 +52,7 @@ type ExternalLinkAction = {
37
52
  newTab?: boolean;
38
53
  onPick?: never;
39
54
  to?: never;
55
+ action?: never;
40
56
  };
41
57
  /**
42
58
  * No action: the option opens a submenu, or it has a checkbox or actions,
@@ -47,12 +63,13 @@ type NoAction = {
47
63
  to?: never;
48
64
  href?: never;
49
65
  newTab?: never;
66
+ action?: never;
50
67
  };
51
68
  /**
52
- * The action of an option: a pick handler, a page of the app, or a page
53
- * out of the app. One option has one action.
69
+ * The action of an option: a pick handler, an action of the registry, a
70
+ * page of the app, or a page out of the app. One option has one action.
54
71
  */
55
- export type OptionAction = PickAction | LinkAction | ExternalLinkAction | NoAction;
72
+ export type OptionAction = PickAction | RegistryAction | LinkAction | ExternalLinkAction | NoAction;
56
73
  /** The place of an option in a sortable Dropdown.Group */
57
74
  export type OptionSortable = {
58
75
  /**