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
@@ -1,270 +0,0 @@
1
- import { useClickOutside } from "../hooks/useClickOutside.js";
2
- import { useTranslation } from "../i18n.js";
3
- import NewZIndex from "../overlays/NewZIndex.js";
4
- import Tooltip from "../overlays/Tooltip.js";
5
- import Portal from "../overlays/Portal.js";
6
- import randomKey from "../utils/randomKey.js";
7
- import { HotKeyContext, HotKeyManagerContext } from "./hotKeyContext.js";
8
- import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
- import { isHotkey } from "is-hotkey-esm";
11
- import { groupBy, isEqual } from "lodash-es";
12
- //#region ../ui/src/actions/HotKey.tsx
13
- var IsRootCoveredContext = React.createContext(false);
14
- var useIsRootCovered = () => useContext(IsRootCoveredContext);
15
- /**
16
- * A layer of keys. While it is mounted, only its own HotKeyListener
17
- * elements work, and the ones of the layers below do not. A dialog is a
18
- * stack.
19
- */
20
- function HotKeyStack({ children, forceStackPriority }) {
21
- const { pushStack } = useContext(HotKeyManagerContext);
22
- const id = useMemo(() => randomKey(), []);
23
- const contextValue = useContext(HotKeyContext);
24
- const newContextValue = useMemo(() => ({
25
- currentStackId: id,
26
- currentStackPriority: forceStackPriority !== void 0 ? forceStackPriority : contextValue.currentStackPriority + 1,
27
- currentListenerPriority: 0,
28
- currentListenerDeets: void 0
29
- }), [
30
- contextValue.currentStackId,
31
- contextValue.currentStackPriority,
32
- forceStackPriority
33
- ]);
34
- useEffect(() => {
35
- return pushStack({
36
- id,
37
- priority: newContextValue.currentStackPriority
38
- });
39
- }, [id, newContextValue.currentStackPriority]);
40
- return /* @__PURE__ */ jsx(HotKeyContext.Provider, {
41
- value: newContextValue,
42
- children
43
- });
44
- }
45
- function findHighestStack(definitions) {
46
- const winner = definitions.reduce((currentWinner, stack) => currentWinner ? currentWinner.priority < stack.priority ? stack : currentWinner : stack, null);
47
- if (!winner) throw new Error("This cannot happen!");
48
- return winner;
49
- }
50
- function findHighestDefinition(definitions) {
51
- return definitions.reduce((currentWinner, stack) => currentWinner ? currentWinner.priority < stack.priority ? stack : currentWinner : stack, null);
52
- }
53
- var GLOBAL_PRIORITY = 1e5;
54
- /**
55
- * Listens to the keys of the whole page. Put it once near the root of the
56
- * app, above every HotKeyListener.
57
- */
58
- function HotKeyManager({ children }) {
59
- const [state, setState] = useState({
60
- stacks: [{
61
- id: "root",
62
- priority: 0
63
- }],
64
- hotKeys: []
65
- });
66
- useEffect(() => {
67
- const handler = (event) => {
68
- const highestStackId = findHighestStack(state.stacks).id;
69
- const winnerDefinition = findHighestDefinition(state.hotKeys.filter((d) => (!d.stackId || d.stackId === highestStackId) && isHotkey(d.hotKey, event)));
70
- if (winnerDefinition) {
71
- event.stopImmediatePropagation();
72
- event.preventDefault();
73
- winnerDefinition.trigger(event);
74
- }
75
- };
76
- document.addEventListener("keydown", handler);
77
- return () => {
78
- document.removeEventListener("keydown", handler);
79
- };
80
- }, [state]);
81
- const addHotKey = (definition) => {
82
- setState((oldState) => {
83
- return {
84
- ...oldState,
85
- hotKeys: [...oldState.hotKeys, definition]
86
- };
87
- });
88
- return () => {
89
- setState((oldState) => {
90
- return {
91
- ...oldState,
92
- hotKeys: oldState.hotKeys.filter((d) => d.trigger !== definition.trigger)
93
- };
94
- });
95
- };
96
- };
97
- const pushStack = (definition) => {
98
- setState((oldState) => {
99
- return {
100
- ...oldState,
101
- stacks: [...oldState.stacks, definition]
102
- };
103
- });
104
- return () => {
105
- setState((oldState) => {
106
- return {
107
- ...oldState,
108
- stacks: oldState.stacks.filter((d) => d.id !== definition.id)
109
- };
110
- });
111
- };
112
- };
113
- const highestStackId = useMemo(() => findHighestStack(state.stacks).id, [state.stacks]);
114
- const activeHotKeys = useMemo(() => {
115
- const matchingHotKeys = state.hotKeys.filter((d) => !d.stackId || d.stackId === highestStackId);
116
- const byHotKey = groupBy(matchingHotKeys, (d) => d.hotKey);
117
- return Object.entries(byHotKey).reduce((acc, [key, definitions]) => {
118
- if (definitions.length > 0) acc[key] = findHighestDefinition(definitions).description;
119
- return acc;
120
- }, {});
121
- }, [state]);
122
- return /* @__PURE__ */ jsx(HotKeyManagerContext.Provider, {
123
- value: {
124
- addHotKey,
125
- pushStack,
126
- activeHotKeys
127
- },
128
- children: /* @__PURE__ */ jsx(IsRootCoveredContext.Provider, {
129
- value: highestStackId !== "root",
130
- children
131
- })
132
- });
133
- }
134
- /**
135
- * Runs `trigger` when the user presses `hotKey`. Of two listeners with the
136
- * same keys, the one that is nested deeper in the tree wins.
137
- */
138
- function HotKeyListener({ children, hotKey, enabled = true, trigger, description: descriptionProp }) {
139
- const { addHotKey } = useContext(HotKeyManagerContext);
140
- const contextValue = useContext(HotKeyContext);
141
- const descriptionRef = useRef(descriptionProp);
142
- if (!isEqual(descriptionRef.current, descriptionProp)) descriptionRef.current = descriptionProp;
143
- const description = descriptionRef.current;
144
- const newContextValue = useMemo(() => ({
145
- currentStackId: contextValue.currentStackId,
146
- currentStackPriority: contextValue.currentStackPriority,
147
- currentListenerPriority: contextValue.currentListenerPriority + 1,
148
- currentListenerDeets: {
149
- hotKey,
150
- description,
151
- enabled
152
- }
153
- }), [
154
- hotKey,
155
- description,
156
- enabled,
157
- contextValue.currentStackId,
158
- contextValue.currentStackPriority,
159
- contextValue.currentListenerPriority
160
- ]);
161
- const [isTriggerPending, setTriggerPending] = useState(false);
162
- const isMountedRef = useRef(true);
163
- useEffect(() => {
164
- isMountedRef.current = true;
165
- return () => {
166
- isMountedRef.current = false;
167
- };
168
- }, []);
169
- const triggerWrapper = useCallback(async (event) => {
170
- try {
171
- setTriggerPending(true);
172
- return await trigger(event);
173
- } finally {
174
- if (isMountedRef.current) setTriggerPending(false);
175
- }
176
- }, [trigger]);
177
- useEffect(() => {
178
- if (enabled) return addHotKey({
179
- stackId: newContextValue.currentStackId,
180
- priority: newContextValue.currentListenerPriority,
181
- hotKey,
182
- description,
183
- trigger: triggerWrapper
184
- });
185
- }, [
186
- newContextValue.currentStackId,
187
- newContextValue.currentListenerPriority,
188
- hotKey,
189
- triggerWrapper,
190
- enabled
191
- ]);
192
- return /* @__PURE__ */ jsx(HotKeyContext.Provider, {
193
- value: newContextValue,
194
- children: typeof children === "function" ? children(isTriggerPending) : children
195
- });
196
- }
197
- var modifierKey = typeof window !== "undefined" && /Mac|iPod|iPhone|iPad/.test(window.navigator.platform) ? "⌘" : "Ctrl";
198
- var keySymbols = {
199
- enter: "↵",
200
- esc: "Esc",
201
- escape: "Esc",
202
- arrowup: "↑",
203
- arrowdown: "↓",
204
- arrowleft: "←",
205
- arrowright: "→"
206
- };
207
- /** The keys of a shortcut, drawn as small keycaps. */
208
- function HotKey({ hotkey }) {
209
- const keys = hotkey.replace(/\bmod\b/g, modifierKey).split(/\+/).map((e) => keySymbols[e.toLowerCase()] || e.charAt(0).toUpperCase() + e.slice(1));
210
- return /* @__PURE__ */ jsx("kbd", {
211
- className: "HotKey",
212
- children: keys.map((key, index) => /* @__PURE__ */ jsx("kbd", {
213
- className: "HotKey__key",
214
- children: key
215
- }, `${index}-${key}`))
216
- });
217
- }
218
- /**
219
- * A tooltip with the keys of the HotKeyListener of the trigger. Put the
220
- * HotKeyListener around it. When there is no listener, or the listener is
221
- * disabled, the tooltip has no keys, and without `label` it does not show.
222
- */
223
- function HotKeyTooltip({ label, hidden, ...props }) {
224
- const { currentListenerDeets } = useContext(HotKeyContext);
225
- const { tm } = useTranslation();
226
- const active = currentListenerDeets?.enabled ? currentListenerDeets : null;
227
- return /* @__PURE__ */ jsx(Tooltip, {
228
- ...props,
229
- label: !hidden && (label ?? (active && tm(active.description))),
230
- shortcut: active?.hotKey
231
- });
232
- }
233
- /**
234
- * A panel at the top of the page with the active keys. Cmd or Ctrl + \\
235
- * opens and closes it. Put it once, inside HotKeyManager.
236
- */
237
- function HotKeyManagerInfo() {
238
- const { t, tm } = useTranslation();
239
- const { activeHotKeys, addHotKey } = useContext(HotKeyManagerContext);
240
- const [visible, setVisible] = useState(false);
241
- const clickOutsideRef = useClickOutside(() => setVisible(false));
242
- const handleToggleVisibility = useCallback(() => setVisible((x) => {
243
- return !x;
244
- }), [setVisible]);
245
- useEffect(() => addHotKey({
246
- priority: GLOBAL_PRIORITY,
247
- hotKey: "mod+\\",
248
- description: { id: "hotkeys.toggleKeyboardShortcuts" },
249
- trigger: handleToggleVisibility
250
- }), [handleToggleVisibility]);
251
- return /* @__PURE__ */ jsx(Fragment, { children: visible && /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(NewZIndex, { children: (zIndex) => /* @__PURE__ */ jsx("div", {
252
- ref: clickOutsideRef,
253
- children: /* @__PURE__ */ jsxs("div", {
254
- className: "HotKeyManagerInfo",
255
- style: { zIndex },
256
- children: [/* @__PURE__ */ jsx("p", {
257
- className: "HotKeyManagerInfo__title",
258
- children: t("hotkeys.info.title")
259
- }), Object.keys(activeHotKeys).length > 0 ? Object.entries(activeHotKeys).map(([hotKey, description]) => /* @__PURE__ */ jsxs("div", {
260
- className: "HotKeyManagerInfo__hotkey",
261
- children: [/* @__PURE__ */ jsx("div", {
262
- className: "HotKeyManagerInfo__hotkey__description",
263
- children: tm(description)
264
- }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(HotKey, { hotkey: hotKey }), " "] })]
265
- }, hotKey)) : /* @__PURE__ */ jsx("p", { children: t("hotkeys.info.empty") })]
266
- })
267
- }) }) }) });
268
- }
269
- //#endregion
270
- export { HotKey, HotKeyListener, HotKeyManager, HotKeyManagerInfo, HotKeyStack, HotKeyTooltip, useIsRootCovered };
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
- import { type TextMessage } from '../Message.js';
3
- export type Callback = (event: Event) => void;
4
- export type ActiveHotKeysType = Record<string, TextMessage>;
5
- export type HotKeyDefinition = {
6
- stackId?: string;
7
- priority: number;
8
- hotKey: string;
9
- description: TextMessage;
10
- trigger: Callback;
11
- };
12
- export type StackDefinition = {
13
- id: string;
14
- priority: number;
15
- };
16
- export type HotKeyManagerContextValue = {
17
- addHotKey(definition: HotKeyDefinition): (() => void) | undefined;
18
- pushStack(stack: StackDefinition): (() => void) | undefined;
19
- activeHotKeys: ActiveHotKeysType;
20
- };
21
- export type HotKeyContextType = {
22
- currentListenerPriority: number;
23
- currentListenerDeets?: {
24
- hotKey: string;
25
- description: TextMessage;
26
- enabled: boolean;
27
- };
28
- currentStackId: string;
29
- currentStackPriority: number;
30
- };
31
- export declare const HotKeyContext: React.Context<HotKeyContextType>;
32
- export declare const HotKeyManagerContext: React.Context<HotKeyManagerContextValue>;
@@ -1,15 +0,0 @@
1
- import React from "react";
2
- //#region ../ui/src/actions/hotKeyContext.ts
3
- var HotKeyContext = React.createContext({
4
- currentListenerPriority: 0,
5
- currentListenerDeets: void 0,
6
- currentStackPriority: 0,
7
- currentStackId: "root"
8
- });
9
- var HotKeyManagerContext = React.createContext({
10
- addHotKey: () => void 0,
11
- pushStack: () => void 0,
12
- activeHotKeys: {}
13
- });
14
- //#endregion
15
- export { HotKeyContext, HotKeyManagerContext };