@redis-ui/components 47.4.0 → 47.5.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 (32) hide show
  1. package/dist/MultiSelect/components/Content/components/SelectAll/SelectAll.cjs +11 -7
  2. package/dist/MultiSelect/components/Content/components/SelectAll/SelectAll.js +12 -8
  3. package/dist/node_modules/@tanstack/hotkeys/dist/constants.cjs +389 -0
  4. package/dist/node_modules/@tanstack/hotkeys/dist/constants.js +383 -0
  5. package/dist/node_modules/@tanstack/hotkeys/dist/format.cjs +22 -0
  6. package/dist/node_modules/@tanstack/hotkeys/dist/format.js +22 -0
  7. package/dist/node_modules/@tanstack/hotkeys/dist/hotkey-manager.cjs +363 -0
  8. package/dist/node_modules/@tanstack/hotkeys/dist/hotkey-manager.js +363 -0
  9. package/dist/node_modules/@tanstack/hotkeys/dist/manager.utils.cjs +111 -0
  10. package/dist/node_modules/@tanstack/hotkeys/dist/manager.utils.js +107 -0
  11. package/dist/node_modules/@tanstack/hotkeys/dist/match.cjs +59 -0
  12. package/dist/node_modules/@tanstack/hotkeys/dist/match.js +59 -0
  13. package/dist/node_modules/@tanstack/hotkeys/dist/parse.cjs +143 -0
  14. package/dist/node_modules/@tanstack/hotkeys/dist/parse.js +141 -0
  15. package/dist/node_modules/@tanstack/react-hotkeys/dist/HotkeysProvider.cjs +10 -0
  16. package/dist/node_modules/@tanstack/react-hotkeys/dist/HotkeysProvider.js +8 -0
  17. package/dist/node_modules/@tanstack/react-hotkeys/dist/useHotkey.cjs +121 -0
  18. package/dist/node_modules/@tanstack/react-hotkeys/dist/useHotkey.js +120 -0
  19. package/dist/node_modules/@tanstack/react-hotkeys/dist/utils.cjs +9 -0
  20. package/dist/node_modules/@tanstack/react-hotkeys/dist/utils.js +9 -0
  21. package/dist/node_modules/@tanstack/store/dist/alien.cjs +183 -0
  22. package/dist/node_modules/@tanstack/store/dist/alien.js +182 -0
  23. package/dist/node_modules/@tanstack/store/dist/atom.cjs +161 -0
  24. package/dist/node_modules/@tanstack/store/dist/atom.js +160 -0
  25. package/dist/node_modules/@tanstack/store/dist/store.cjs +25 -0
  26. package/dist/node_modules/@tanstack/store/dist/store.js +25 -0
  27. package/package.json +3 -3
  28. package/skills/redis-ui-components/SKILL.md +1 -1
  29. package/skills/redis-ui-components/references/Icons.md +3 -3
  30. package/skills/redis-ui-components/references/SideBar.md +8 -8
  31. package/dist/node_modules/react-hotkeys-hook/dist/react-hotkeys-hook.esm.cjs +0 -289
  32. package/dist/node_modules/react-hotkeys-hook/dist/react-hotkeys-hook.esm.js +0 -288
@@ -1,6 +1,6 @@
1
1
  require("../../../../../_virtual/_rolldown/runtime.cjs");
2
2
  const require_TextButton = require("../../../../../Button/TextButton/TextButton.cjs");
3
- const require_react_hotkeys_hook_esm = require("../../../../../node_modules/react-hotkeys-hook/dist/react-hotkeys-hook.esm.cjs");
3
+ const require_useHotkey = require("../../../../../node_modules/@tanstack/react-hotkeys/dist/useHotkey.cjs");
4
4
  const require_Context = require("../../../Context/Context.cjs");
5
5
  let react_jsx_runtime = require("react/jsx-runtime");
6
6
  let react = require("react");
@@ -8,13 +8,17 @@ let react = require("react");
8
8
  var SelectAllAction = ({ selectAllTitle = "Select All", unselectAllTitle = "Unselect All", ...restProps }) => {
9
9
  const { getSelectAllApi, hasSearch } = require_Context.useMultiSelectContext();
10
10
  const { isAllSelected, hasSelectable, unselectAll, selectAll } = (0, react.useMemo)(() => getSelectAllApi(hasSearch), [getSelectAllApi, hasSearch]);
11
- const setHotkeyComponent = require_react_hotkeys_hook_esm.useHotkeys("mod+a", () => isAllSelected ? unselectAll() : selectAll(), { preventDefault: true }, [
12
- isAllSelected,
13
- selectAll,
14
- unselectAll
15
- ]);
11
+ const hotkeyTargetRef = (0, react.useRef)(null);
12
+ require_useHotkey.useHotkey("Mod+A", () => isAllSelected ? unselectAll() : selectAll(), {
13
+ target: hotkeyTargetRef,
14
+ preventDefault: true,
15
+ stopPropagation: false,
16
+ ignoreInputs: true
17
+ });
16
18
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_TextButton.default, {
17
- ref: (0, react.useCallback)((ref) => setHotkeyComponent(ref?.closest("div[role=listbox]") || ref), [setHotkeyComponent]),
19
+ ref: (0, react.useCallback)((ref) => {
20
+ hotkeyTargetRef.current = ref?.closest("div[role=listbox]") || ref || null;
21
+ }, []),
18
22
  disabled: !hasSelectable,
19
23
  variant: "primary-inline",
20
24
  ...restProps,
@@ -1,19 +1,23 @@
1
1
  import TextButton from "../../../../../Button/TextButton/TextButton.js";
2
- import { useHotkeys } from "../../../../../node_modules/react-hotkeys-hook/dist/react-hotkeys-hook.esm.js";
2
+ import { useHotkey } from "../../../../../node_modules/@tanstack/react-hotkeys/dist/useHotkey.js";
3
3
  import { useMultiSelectContext } from "../../../Context/Context.js";
4
4
  import { jsx } from "react/jsx-runtime";
5
- import { useCallback, useMemo } from "react";
5
+ import { useCallback, useMemo, useRef } from "react";
6
6
  //#region src/MultiSelect/components/Content/components/SelectAll/SelectAll.tsx
7
7
  var SelectAllAction = ({ selectAllTitle = "Select All", unselectAllTitle = "Unselect All", ...restProps }) => {
8
8
  const { getSelectAllApi, hasSearch } = useMultiSelectContext();
9
9
  const { isAllSelected, hasSelectable, unselectAll, selectAll } = useMemo(() => getSelectAllApi(hasSearch), [getSelectAllApi, hasSearch]);
10
- const setHotkeyComponent = useHotkeys("mod+a", () => isAllSelected ? unselectAll() : selectAll(), { preventDefault: true }, [
11
- isAllSelected,
12
- selectAll,
13
- unselectAll
14
- ]);
10
+ const hotkeyTargetRef = useRef(null);
11
+ useHotkey("Mod+A", () => isAllSelected ? unselectAll() : selectAll(), {
12
+ target: hotkeyTargetRef,
13
+ preventDefault: true,
14
+ stopPropagation: false,
15
+ ignoreInputs: true
16
+ });
15
17
  return /* @__PURE__ */ jsx(TextButton, {
16
- ref: useCallback((ref) => setHotkeyComponent(ref?.closest("div[role=listbox]") || ref), [setHotkeyComponent]),
18
+ ref: useCallback((ref) => {
19
+ hotkeyTargetRef.current = ref?.closest("div[role=listbox]") || ref || null;
20
+ }, []),
17
21
  disabled: !hasSelectable,
18
22
  variant: "primary-inline",
19
23
  ...restProps,
@@ -0,0 +1,389 @@
1
+ //#region ../../node_modules/@tanstack/hotkeys/dist/constants.js
2
+ /**
3
+ * Detects the current platform based on browser navigator properties.
4
+ *
5
+ * Used internally to resolve platform-adaptive modifiers like 'Mod' (Command on Mac,
6
+ * Control elsewhere) and for platform-specific hotkey formatting.
7
+ *
8
+ * @returns The detected platform: 'mac', 'windows', or 'linux'
9
+ * @remarks Defaults to 'linux' in SSR environments where navigator is undefined
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const platform = detectPlatform() // 'mac' | 'windows' | 'linux'
14
+ * const modifier = resolveModifier('Mod', platform) // 'Meta' on Mac, 'Control' elsewhere
15
+ * ```
16
+ */
17
+ function detectPlatform() {
18
+ if (typeof navigator === "undefined") return "linux";
19
+ const platform = navigator.platform?.toLowerCase() ?? "";
20
+ const userAgent = navigator.userAgent?.toLowerCase() ?? "";
21
+ if (platform.includes("mac") || userAgent.includes("mac")) return "mac";
22
+ if (platform.includes("win") || userAgent.includes("win")) return "windows";
23
+ return "linux";
24
+ }
25
+ /**
26
+ * Canonical order for modifiers in normalized hotkey strings.
27
+ *
28
+ * Defines the standard order in which modifiers should appear when formatting
29
+ * hotkeys. This ensures consistent, predictable output across the library.
30
+ *
31
+ * Order: Control → Alt → Shift → Meta
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * // Input: 'Shift+Control+Meta+S'
36
+ * // Normalized: 'Control+Alt+Shift+Meta+S' (following MODIFIER_ORDER)
37
+ * ```
38
+ */
39
+ var MODIFIER_ORDER = [
40
+ "Control",
41
+ "Alt",
42
+ "Shift",
43
+ "Meta"
44
+ ];
45
+ new Set(MODIFIER_ORDER);
46
+ /**
47
+ * Maps modifier key aliases to their canonical form or platform-adaptive 'Mod'.
48
+ *
49
+ * This map allows users to write hotkeys using various aliases (e.g., 'Ctrl', 'Cmd', 'Option')
50
+ * which are then normalized to canonical names ('Control', 'Meta', 'Alt') or the
51
+ * platform-adaptive 'Mod' token.
52
+ *
53
+ * The 'Mod' and 'CommandOrControl' aliases are resolved at runtime via `resolveModifier()`
54
+ * based on the detected platform (Command on Mac, Control elsewhere).
55
+ *
56
+ * @remarks Case-insensitive lookups are supported via lowercase variants
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * MODIFIER_ALIASES['Ctrl'] // 'Control'
61
+ * MODIFIER_ALIASES['Cmd'] // 'Meta'
62
+ * MODIFIER_ALIASES['Mod'] // 'Mod' (resolved at runtime)
63
+ * ```
64
+ */
65
+ var MODIFIER_ALIASES = {
66
+ Control: "Control",
67
+ Ctrl: "Control",
68
+ control: "Control",
69
+ ctrl: "Control",
70
+ Shift: "Shift",
71
+ shift: "Shift",
72
+ Alt: "Alt",
73
+ Option: "Alt",
74
+ alt: "Alt",
75
+ option: "Alt",
76
+ Command: "Meta",
77
+ Cmd: "Meta",
78
+ Meta: "Meta",
79
+ command: "Meta",
80
+ cmd: "Meta",
81
+ meta: "Meta",
82
+ OS: "Meta",
83
+ os: "Meta",
84
+ Win: "Meta",
85
+ win: "Meta",
86
+ CommandOrControl: "Mod",
87
+ Mod: "Mod",
88
+ commandorcontrol: "Mod",
89
+ mod: "Mod"
90
+ };
91
+ /**
92
+ * Resolves the platform-adaptive 'Mod' modifier to the appropriate canonical modifier.
93
+ *
94
+ * The 'Mod' token represents the "primary modifier" on each platform:
95
+ * - macOS: 'Meta' (Command key ⌘)
96
+ * - Windows/Linux: 'Control' (Ctrl key)
97
+ *
98
+ * This enables cross-platform hotkey definitions like 'Mod+S' that automatically
99
+ * map to Command+S on Mac and Ctrl+S on Windows/Linux.
100
+ *
101
+ * @param modifier - The modifier to resolve. If 'Mod', resolves based on platform.
102
+ * @param platform - The target platform. Defaults to auto-detection.
103
+ * @returns The canonical modifier name ('Control', 'Shift', 'Alt', or 'Meta')
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * resolveModifier('Mod', 'mac') // 'Meta'
108
+ * resolveModifier('Mod', 'windows') // 'Control'
109
+ * resolveModifier('Control', 'mac') // 'Control' (unchanged)
110
+ * ```
111
+ */
112
+ function resolveModifier(modifier, platform = detectPlatform()) {
113
+ if (modifier === "Mod") return platform === "mac" ? "Meta" : "Control";
114
+ return modifier;
115
+ }
116
+ /**
117
+ * Set of all valid letter keys (A-Z).
118
+ *
119
+ * Used for validation and type checking. Letter keys are matched case-insensitively
120
+ * in hotkey matching, but normalized to uppercase in canonical form.
121
+ */
122
+ var LETTER_KEYS = new Set([
123
+ "A",
124
+ "B",
125
+ "C",
126
+ "D",
127
+ "E",
128
+ "F",
129
+ "G",
130
+ "H",
131
+ "I",
132
+ "J",
133
+ "K",
134
+ "L",
135
+ "M",
136
+ "N",
137
+ "O",
138
+ "P",
139
+ "Q",
140
+ "R",
141
+ "S",
142
+ "T",
143
+ "U",
144
+ "V",
145
+ "W",
146
+ "X",
147
+ "Y",
148
+ "Z"
149
+ ]);
150
+ /**
151
+ * Set of all valid number keys (0-9).
152
+ *
153
+ * Note: Number keys are affected by Shift (Shift+1 → '!' on US layout),
154
+ * so they're excluded from Shift-based hotkey combinations to avoid
155
+ * layout-dependent behavior.
156
+ */
157
+ var NUMBER_KEYS = new Set([
158
+ "0",
159
+ "1",
160
+ "2",
161
+ "3",
162
+ "4",
163
+ "5",
164
+ "6",
165
+ "7",
166
+ "8",
167
+ "9"
168
+ ]);
169
+ /**
170
+ * Set of all valid function keys (F1-F12).
171
+ *
172
+ * Function keys are commonly used for system shortcuts (e.g., F12 for DevTools,
173
+ * Alt+F4 to close windows) and application-specific commands.
174
+ */
175
+ var FUNCTION_KEYS = new Set([
176
+ "F1",
177
+ "F2",
178
+ "F3",
179
+ "F4",
180
+ "F5",
181
+ "F6",
182
+ "F7",
183
+ "F8",
184
+ "F9",
185
+ "F10",
186
+ "F11",
187
+ "F12"
188
+ ]);
189
+ /**
190
+ * Set of all valid navigation keys for cursor movement and document navigation.
191
+ *
192
+ * Includes arrow keys, Home/End (line navigation), and PageUp/PageDown (page navigation).
193
+ * These keys are commonly combined with modifiers for selection (Shift+ArrowUp) or
194
+ * navigation shortcuts (Alt+ArrowLeft for back).
195
+ */
196
+ var NAVIGATION_KEYS = new Set([
197
+ "ArrowUp",
198
+ "ArrowDown",
199
+ "ArrowLeft",
200
+ "ArrowRight",
201
+ "Home",
202
+ "End",
203
+ "PageUp",
204
+ "PageDown"
205
+ ]);
206
+ /**
207
+ * Set of all valid editing and special keys.
208
+ *
209
+ * Includes keys commonly used for text editing (Enter, Backspace, Delete, Tab) and
210
+ * special actions (Escape, Space). These keys are frequently combined with modifiers
211
+ * for editor shortcuts (Mod+Enter to submit, Shift+Tab to go back).
212
+ */
213
+ var EDITING_KEYS = new Set([
214
+ "Enter",
215
+ "Escape",
216
+ "Space",
217
+ "Tab",
218
+ "Backspace",
219
+ "Delete"
220
+ ]);
221
+ /**
222
+ * Set of all valid punctuation keys commonly used in keyboard shortcuts.
223
+ *
224
+ * These are the literal characters as they appear in `KeyboardEvent.key` (layout-dependent,
225
+ * typically US keyboard layout). Common shortcuts include:
226
+ * - `Mod+/` - Toggle comment
227
+ * - `Mod+[` / `Mod+]` - Indent/outdent
228
+ * - `Mod+=` / `Mod+-` - Zoom in/out
229
+ *
230
+ * Note: Punctuation keys are affected by Shift (Shift+',' → '<' on US layout),
231
+ * so they're excluded from Shift-based hotkey combinations to avoid layout-dependent behavior.
232
+ */
233
+ var PUNCTUATION_KEYS = new Set([
234
+ "/",
235
+ "[",
236
+ "]",
237
+ "\\",
238
+ "=",
239
+ "-",
240
+ ",",
241
+ ".",
242
+ ";",
243
+ "`"
244
+ ]);
245
+ /**
246
+ * Maps `KeyboardEvent.code` values for punctuation keys to their canonical characters.
247
+ *
248
+ * On macOS, holding the Option (Alt) key transforms punctuation keys into special characters
249
+ * (e.g., Option+Minus → en-dash '–'), causing `event.key` to differ from the expected character.
250
+ * However, `event.code` still reports the physical key (e.g., 'Minus'). This map enables
251
+ * falling back to `event.code` for punctuation keys, similar to the existing `Key*`/`Digit*`
252
+ * fallbacks for letters and digits.
253
+ */
254
+ var PUNCTUATION_CODE_MAP = {
255
+ Backquote: "`",
256
+ Backslash: "\\",
257
+ BracketLeft: "[",
258
+ BracketRight: "]",
259
+ Comma: ",",
260
+ Equal: "=",
261
+ Minus: "-",
262
+ Period: ".",
263
+ Semicolon: ";",
264
+ Slash: "/"
265
+ };
266
+ new Set([
267
+ ...LETTER_KEYS,
268
+ ...NUMBER_KEYS,
269
+ ...FUNCTION_KEYS,
270
+ ...NAVIGATION_KEYS,
271
+ ...EDITING_KEYS,
272
+ ...PUNCTUATION_KEYS
273
+ ]);
274
+ /**
275
+ * Maps key name aliases to their canonical form.
276
+ *
277
+ * Handles common variations and alternative names for keys to provide a more
278
+ * forgiving API. For example, users can write 'Esc', 'esc', or 'escape' and
279
+ * they'll all normalize to 'Escape'.
280
+ *
281
+ * This map is used internally by `normalizeKeyName()` to convert user input
282
+ * into the canonical key names used throughout the library.
283
+ *
284
+ * @remarks Case-insensitive lookups are supported via lowercase variants
285
+ *
286
+ * @example
287
+ * ```ts
288
+ * KEY_ALIASES['Esc'] // 'Escape'
289
+ * KEY_ALIASES['Del'] // 'Delete'
290
+ * KEY_ALIASES['Up'] // 'ArrowUp'
291
+ * ```
292
+ */
293
+ var KEY_ALIASES = {
294
+ Esc: "Escape",
295
+ esc: "Escape",
296
+ escape: "Escape",
297
+ Return: "Enter",
298
+ return: "Enter",
299
+ enter: "Enter",
300
+ " ": "Space",
301
+ space: "Space",
302
+ Spacebar: "Space",
303
+ spacebar: "Space",
304
+ tab: "Tab",
305
+ backspace: "Backspace",
306
+ Del: "Delete",
307
+ del: "Delete",
308
+ delete: "Delete",
309
+ Up: "ArrowUp",
310
+ up: "ArrowUp",
311
+ arrowup: "ArrowUp",
312
+ Down: "ArrowDown",
313
+ down: "ArrowDown",
314
+ arrowdown: "ArrowDown",
315
+ Left: "ArrowLeft",
316
+ left: "ArrowLeft",
317
+ arrowleft: "ArrowLeft",
318
+ Right: "ArrowRight",
319
+ right: "ArrowRight",
320
+ arrowright: "ArrowRight",
321
+ home: "Home",
322
+ end: "End",
323
+ pageup: "PageUp",
324
+ pagedown: "PageDown",
325
+ PgUp: "PageUp",
326
+ PgDn: "PageDown",
327
+ pgup: "PageUp",
328
+ pgdn: "PageDown"
329
+ };
330
+ /**
331
+ * Normalizes a key name to its canonical form.
332
+ *
333
+ * Converts various key name formats (aliases, case variations) into the standard
334
+ * canonical names used throughout the library. This enables a more forgiving API
335
+ * where users can write keys in different ways and still get correct behavior.
336
+ *
337
+ * Normalization rules:
338
+ * 1. Check aliases first (e.g., 'Esc' → 'Escape', 'Del' → 'Delete')
339
+ * 2. Single letters → uppercase (e.g., 'a' → 'A', 's' → 'S')
340
+ * 3. Function keys → uppercase (e.g., 'f1' → 'F1', 'F12' → 'F12')
341
+ * 4. Other keys → returned as-is (already canonical or unknown)
342
+ *
343
+ * @param key - The key name to normalize (can be an alias, lowercase, etc.)
344
+ * @returns The canonical key name
345
+ *
346
+ * @example
347
+ * ```ts
348
+ * normalizeKeyName('esc') // 'Escape'
349
+ * normalizeKeyName('a') // 'A'
350
+ * normalizeKeyName('f1') // 'F1'
351
+ * normalizeKeyName('ArrowUp') // 'ArrowUp' (already canonical)
352
+ * ```
353
+ */
354
+ function isSingleLetterKey(key) {
355
+ return /^\p{Letter}$/u.test(key);
356
+ }
357
+ /**
358
+ * Normalizes a key name to its canonical form.
359
+ *
360
+ * @param key - The key name to normalize (can be an alias, lowercase, etc.)
361
+ * @returns The canonical key name
362
+ *
363
+ * @example
364
+ * ```ts
365
+ * normalizeKeyName('esc') // 'Escape'
366
+ * normalizeKeyName('a') // 'A'
367
+ * normalizeKeyName('f1') // 'F1'
368
+ * normalizeKeyName('ArrowUp') // 'ArrowUp' (already canonical)
369
+ * ```
370
+ */
371
+ function normalizeKeyName(key) {
372
+ if (!key) return "";
373
+ if (key in KEY_ALIASES) return KEY_ALIASES[key];
374
+ if (isSingleLetterKey(key)) {
375
+ const upper = key.toUpperCase();
376
+ return upper.length === 1 ? upper : key;
377
+ }
378
+ const upperKey = key.toUpperCase();
379
+ if (/^F([1-9]|1[0-2])$/.test(upperKey)) return upperKey;
380
+ return key;
381
+ }
382
+ //#endregion
383
+ exports.MODIFIER_ALIASES = MODIFIER_ALIASES;
384
+ exports.MODIFIER_ORDER = MODIFIER_ORDER;
385
+ exports.PUNCTUATION_CODE_MAP = PUNCTUATION_CODE_MAP;
386
+ exports.detectPlatform = detectPlatform;
387
+ exports.isSingleLetterKey = isSingleLetterKey;
388
+ exports.normalizeKeyName = normalizeKeyName;
389
+ exports.resolveModifier = resolveModifier;