@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
@@ -0,0 +1,363 @@
1
+ const require_constants = require("./constants.cjs");
2
+ const require_parse = require("./parse.cjs");
3
+ const require_format = require("./format.cjs");
4
+ const require_match = require("./match.cjs");
5
+ const require_manager_utils = require("./manager.utils.cjs");
6
+ const require_store = require("../../store/dist/store.cjs");
7
+ //#region ../../node_modules/@tanstack/hotkeys/dist/hotkey-manager.js
8
+ var registrationIdCounter = 0;
9
+ /**
10
+ * Generates a unique ID for hotkey registrations.
11
+ */
12
+ function generateId() {
13
+ return `hotkey_${++registrationIdCounter}`;
14
+ }
15
+ /**
16
+ * Singleton manager for hotkey registrations.
17
+ *
18
+ * This class provides a centralized way to register and manage keyboard hotkeys.
19
+ * It uses a single event listener for efficiency, regardless of how many hotkeys
20
+ * are registered.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const manager = HotkeyManager.getInstance()
25
+ *
26
+ * const unregister = manager.register('Mod+S', (event, context) => {
27
+ * console.log('Save triggered!')
28
+ * })
29
+ *
30
+ * // Later, to unregister:
31
+ * unregister()
32
+ * ```
33
+ */
34
+ var HotkeyManager = class HotkeyManager {
35
+ static #instance = null;
36
+ #platform;
37
+ #targetListeners = /* @__PURE__ */ new Map();
38
+ #targetRegistrations = /* @__PURE__ */ new Map();
39
+ constructor() {
40
+ this.registrations = new require_store.Store(/* @__PURE__ */ new Map());
41
+ this.#platform = require_constants.detectPlatform();
42
+ }
43
+ /**
44
+ * Gets the singleton instance of HotkeyManager.
45
+ */
46
+ static getInstance() {
47
+ if (!HotkeyManager.#instance) HotkeyManager.#instance = new HotkeyManager();
48
+ return HotkeyManager.#instance;
49
+ }
50
+ /**
51
+ * Resets the singleton instance. Useful for testing.
52
+ */
53
+ static resetInstance() {
54
+ if (HotkeyManager.#instance) {
55
+ HotkeyManager.#instance.destroy();
56
+ HotkeyManager.#instance = null;
57
+ }
58
+ }
59
+ /**
60
+ * Registers a hotkey handler and returns a handle for updating the registration.
61
+ *
62
+ * The returned handle allows updating the callback and options without
63
+ * re-registering, which is useful for avoiding stale closures in React.
64
+ *
65
+ * @param hotkey - The hotkey string (e.g., 'Mod+S') or RawHotkey object
66
+ * @param callback - The function to call when the hotkey is pressed
67
+ * @param options - Options for the hotkey behavior
68
+ * @returns A handle for managing the registration
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * const handle = manager.register('Mod+S', callback)
73
+ *
74
+ * // Update callback without re-registering (avoids stale closures)
75
+ * handle.callback = newCallback
76
+ *
77
+ * // Update options
78
+ * handle.setOptions({ enabled: false })
79
+ *
80
+ * // Unregister when done
81
+ * handle.unregister()
82
+ * ```
83
+ */
84
+ register(hotkey, callback, options = {}) {
85
+ if (typeof document === "undefined" && !options.target) {
86
+ let currentCallback = callback;
87
+ return {
88
+ id: generateId(),
89
+ unregister: () => {},
90
+ get callback() {
91
+ return currentCallback;
92
+ },
93
+ set callback(newCallback) {
94
+ currentCallback = newCallback;
95
+ },
96
+ setOptions: () => {},
97
+ get isActive() {
98
+ return false;
99
+ }
100
+ };
101
+ }
102
+ const id = generateId();
103
+ const platform = options.platform ?? this.#platform;
104
+ const parsedHotkey = typeof hotkey === "string" ? require_parse.parseHotkey(hotkey, platform) : require_parse.rawHotkeyToParsedHotkey(hotkey, platform);
105
+ const hotkeyStr = typeof hotkey === "string" ? hotkey : require_format.formatHotkey(parsedHotkey);
106
+ const target = options.target ?? document;
107
+ const conflictBehavior = options.conflictBehavior ?? "warn";
108
+ const conflictingRegistration = this.#findConflictingRegistration(hotkeyStr, target);
109
+ if (conflictingRegistration) require_manager_utils.handleConflict(conflictingRegistration.id, hotkeyStr, conflictBehavior, (id) => this.#unregister(id));
110
+ const resolvedIgnoreInputs = options.ignoreInputs ?? require_manager_utils.getDefaultIgnoreInputs(parsedHotkey);
111
+ const registration = {
112
+ id,
113
+ hotkey: hotkeyStr,
114
+ parsedHotkey,
115
+ callback,
116
+ options: {
117
+ ...require_manager_utils.defaultHotkeyOptions,
118
+ requireReset: false,
119
+ ...options,
120
+ platform,
121
+ ignoreInputs: resolvedIgnoreInputs
122
+ },
123
+ hasFired: false,
124
+ triggerCount: 0,
125
+ target
126
+ };
127
+ this.registrations.setState((prev) => new Map(prev).set(id, registration));
128
+ if (!this.#targetRegistrations.has(target)) this.#targetRegistrations.set(target, /* @__PURE__ */ new Set());
129
+ this.#targetRegistrations.get(target).add(id);
130
+ this.#ensureListenersForTarget(target);
131
+ const manager = this;
132
+ return {
133
+ get id() {
134
+ return id;
135
+ },
136
+ unregister: () => {
137
+ manager.#unregister(id);
138
+ },
139
+ get callback() {
140
+ return manager.registrations.state.get(id)?.callback ?? callback;
141
+ },
142
+ set callback(newCallback) {
143
+ const reg = manager.registrations.state.get(id);
144
+ if (reg) reg.callback = newCallback;
145
+ },
146
+ setOptions: (newOptions) => {
147
+ manager.registrations.setState((prev) => {
148
+ const reg = prev.get(id);
149
+ if (reg) {
150
+ const next = new Map(prev);
151
+ next.set(id, {
152
+ ...reg,
153
+ options: {
154
+ ...reg.options,
155
+ ...newOptions
156
+ }
157
+ });
158
+ return next;
159
+ }
160
+ return prev;
161
+ });
162
+ },
163
+ get isActive() {
164
+ return manager.registrations.state.has(id);
165
+ }
166
+ };
167
+ }
168
+ /**
169
+ * Unregisters a hotkey by its registration ID.
170
+ */
171
+ #unregister(id) {
172
+ const registration = this.registrations.state.get(id);
173
+ if (!registration) return;
174
+ const target = registration.target;
175
+ this.registrations.setState((prev) => {
176
+ const next = new Map(prev);
177
+ next.delete(id);
178
+ return next;
179
+ });
180
+ const targetRegs = this.#targetRegistrations.get(target);
181
+ if (targetRegs) {
182
+ targetRegs.delete(id);
183
+ if (targetRegs.size === 0) this.#removeListenersForTarget(target);
184
+ }
185
+ }
186
+ /**
187
+ * Ensures event listeners are attached for a specific target.
188
+ */
189
+ #ensureListenersForTarget(target) {
190
+ if (typeof document === "undefined") return;
191
+ if (this.#targetListeners.has(target)) return;
192
+ const keydownHandler = this.#createTargetKeyDownHandler(target);
193
+ const keyupHandler = this.#createTargetKeyUpHandler(target);
194
+ target.addEventListener("keydown", keydownHandler);
195
+ target.addEventListener("keyup", keyupHandler);
196
+ this.#targetListeners.set(target, {
197
+ keydown: keydownHandler,
198
+ keyup: keyupHandler
199
+ });
200
+ }
201
+ /**
202
+ * Removes event listeners for a specific target.
203
+ */
204
+ #removeListenersForTarget(target) {
205
+ if (typeof document === "undefined") return;
206
+ const listeners = this.#targetListeners.get(target);
207
+ if (!listeners) return;
208
+ target.removeEventListener("keydown", listeners.keydown);
209
+ target.removeEventListener("keyup", listeners.keyup);
210
+ this.#targetListeners.delete(target);
211
+ this.#targetRegistrations.delete(target);
212
+ }
213
+ /**
214
+ * Processes keyboard events for a specific target and event type.
215
+ */
216
+ #processTargetEvent(event, target, eventType) {
217
+ const targetRegs = this.#targetRegistrations.get(target);
218
+ if (!targetRegs) return;
219
+ for (const id of targetRegs) {
220
+ const registration = this.registrations.state.get(id);
221
+ if (!registration) continue;
222
+ if (!require_manager_utils.isEventForTarget(event, target)) continue;
223
+ if (!registration.options.enabled) continue;
224
+ if (registration.options.ignoreInputs !== false) {
225
+ if (require_manager_utils.shouldIgnoreInputEvent(event, target, registration.target)) continue;
226
+ }
227
+ if (eventType === "keydown") {
228
+ if (registration.options.eventType !== "keydown") continue;
229
+ if (require_match.matchesKeyboardEvent(event, registration.parsedHotkey, registration.options.platform)) {
230
+ if (registration.options.preventDefault) event.preventDefault();
231
+ if (registration.options.stopPropagation) event.stopPropagation();
232
+ if (!registration.options.requireReset || !registration.hasFired) {
233
+ this.#executeHotkeyCallback(registration, event);
234
+ if (registration.options.requireReset) registration.hasFired = true;
235
+ }
236
+ }
237
+ } else {
238
+ if (registration.options.eventType === "keyup") {
239
+ if (require_match.matchesKeyboardEvent(event, registration.parsedHotkey, registration.options.platform)) this.#executeHotkeyCallback(registration, event);
240
+ }
241
+ if (registration.options.requireReset && registration.hasFired) {
242
+ if (this.#shouldResetRegistration(registration, event)) registration.hasFired = false;
243
+ }
244
+ }
245
+ }
246
+ }
247
+ /**
248
+ * Executes a hotkey callback with proper event handling.
249
+ */
250
+ #executeHotkeyCallback(registration, event) {
251
+ if (registration.options.preventDefault) event.preventDefault();
252
+ if (registration.options.stopPropagation) event.stopPropagation();
253
+ registration.triggerCount++;
254
+ this.registrations.setState((prev) => new Map(prev));
255
+ const context = {
256
+ hotkey: registration.hotkey,
257
+ parsedHotkey: registration.parsedHotkey
258
+ };
259
+ registration.callback(event, context);
260
+ }
261
+ /**
262
+ * Creates a keydown handler for a specific target.
263
+ */
264
+ #createTargetKeyDownHandler(target) {
265
+ return (event) => {
266
+ this.#processTargetEvent(event, target, "keydown");
267
+ };
268
+ }
269
+ /**
270
+ * Creates a keyup handler for a specific target.
271
+ */
272
+ #createTargetKeyUpHandler(target) {
273
+ return (event) => {
274
+ this.#processTargetEvent(event, target, "keyup");
275
+ };
276
+ }
277
+ /**
278
+ * Finds an existing registration with the same hotkey and target.
279
+ */
280
+ #findConflictingRegistration(hotkey, target) {
281
+ for (const registration of this.registrations.state.values()) if (registration.hotkey === hotkey && registration.target === target) return registration;
282
+ return null;
283
+ }
284
+ /**
285
+ * Determines if a registration should be reset based on the keyup event.
286
+ */
287
+ #shouldResetRegistration(registration, event) {
288
+ const parsed = registration.parsedHotkey;
289
+ const releasedKey = require_constants.normalizeKeyName(event.key);
290
+ const parsedKeyNormalized = parsed.key.length === 1 ? parsed.key.toUpperCase() : parsed.key;
291
+ if ((releasedKey.length === 1 ? releasedKey.toUpperCase() : releasedKey) === parsedKeyNormalized) return true;
292
+ if (parsed.ctrl && releasedKey === "Control") return true;
293
+ if (parsed.shift && releasedKey === "Shift") return true;
294
+ if (parsed.alt && releasedKey === "Alt") return true;
295
+ if (parsed.meta && releasedKey === "Meta") return true;
296
+ return false;
297
+ }
298
+ /**
299
+ * Triggers a registration's callback programmatically from devtools.
300
+ * Creates a synthetic KeyboardEvent and invokes the callback.
301
+ *
302
+ * @param id - The registration ID to trigger
303
+ * @returns True if the registration was found and triggered
304
+ */
305
+ triggerRegistration(id) {
306
+ const registration = this.registrations.state.get(id);
307
+ if (!registration) return false;
308
+ const parsed = registration.parsedHotkey;
309
+ const syntheticEvent = new KeyboardEvent(registration.options.eventType ?? "keydown", {
310
+ key: parsed.key,
311
+ ctrlKey: parsed.ctrl,
312
+ shiftKey: parsed.shift,
313
+ altKey: parsed.alt,
314
+ metaKey: parsed.meta,
315
+ bubbles: true,
316
+ cancelable: true
317
+ });
318
+ registration.triggerCount++;
319
+ this.registrations.setState((prev) => new Map(prev));
320
+ registration.callback(syntheticEvent, {
321
+ hotkey: registration.hotkey,
322
+ parsedHotkey: registration.parsedHotkey
323
+ });
324
+ return true;
325
+ }
326
+ /**
327
+ * Gets the number of registered hotkeys.
328
+ */
329
+ getRegistrationCount() {
330
+ return this.registrations.state.size;
331
+ }
332
+ /**
333
+ * Checks if a specific hotkey is registered.
334
+ *
335
+ * @param hotkey - The hotkey string to check
336
+ * @param target - Optional target element to match (if provided, both hotkey and target must match)
337
+ * @returns True if a matching registration exists
338
+ */
339
+ isRegistered(hotkey, target) {
340
+ for (const registration of this.registrations.state.values()) if (registration.hotkey === hotkey) {
341
+ if (target === void 0 || registration.target === target) return true;
342
+ }
343
+ return false;
344
+ }
345
+ /**
346
+ * Destroys the manager and removes all listeners.
347
+ */
348
+ destroy() {
349
+ for (const target of this.#targetListeners.keys()) this.#removeListenersForTarget(target);
350
+ this.registrations.setState(() => /* @__PURE__ */ new Map());
351
+ this.#targetListeners.clear();
352
+ this.#targetRegistrations.clear();
353
+ }
354
+ };
355
+ /**
356
+ * Gets the singleton HotkeyManager instance.
357
+ * Convenience function for accessing the manager.
358
+ */
359
+ function getHotkeyManager() {
360
+ return HotkeyManager.getInstance();
361
+ }
362
+ //#endregion
363
+ exports.getHotkeyManager = getHotkeyManager;