MCPcopy Index your code
hub / github.com/TanStack/devtools / HotkeyConfig

Function HotkeyConfig

packages/devtools/src/tabs/hotkey-config.tsx:24–97  ·  view source on GitHub ↗
(props: HotkeyConfigProps)

Source from the content-addressed store, hash-verified

22}
23
24export const HotkeyConfig = (props: HotkeyConfigProps) => {
25 const styles = createStyles()
26
27 const toggleModifier = (modifier: KeyboardKey) => {
28 if (props.hotkey.includes(modifier)) {
29 props.onHotkeyChange(props.hotkey.filter((key) => key !== modifier))
30 } else {
31 const existingModifiers = props.hotkey.filter((key) =>
32 props.modifiers.includes(key as any),
33 )
34 const otherKeys = props.hotkey.filter(
35 (key) => !props.modifiers.includes(key as any),
36 )
37 props.onHotkeyChange([...existingModifiers, modifier, ...otherKeys])
38 }
39 }
40
41 const getNonModifierValue = () => {
42 return props.hotkey
43 .filter((key) => !props.modifiers.includes(key as any))
44 .join('+')
45 }
46
47 const handleKeyInput = (input: string) => {
48 const makeModifierArray = (key: string) => {
49 if (key.length === 1) return [uppercaseFirstLetter(key)]
50 const modifiersArray: Array<string> = []
51 for (const character of key) {
52 const newLetter = uppercaseFirstLetter(character)
53 if (!modifiersArray.includes(newLetter)) modifiersArray.push(newLetter)
54 }
55 return modifiersArray
56 }
57
58 const hotkeyModifiers = props.hotkey.filter((key) =>
59 props.modifiers.includes(key as any),
60 )
61 const newKeys = input
62 .split('+')
63 .flatMap((key) => makeModifierArray(key))
64 .filter(Boolean)
65 props.onHotkeyChange([...hotkeyModifiers, ...newKeys])
66 }
67
68 const getDisplayHotkey = () => {
69 return props.hotkey.join(' + ')
70 }
71
72 return (
73 <div class={styles().settingsGroup}>
74 <h4 style={{ margin: 0 }}>{props.description}</h4>
75 <div class={styles().settingsModifiers}>
76 <Show keyed when={props.hotkey}>
77 {props.modifiers.map((modifier) => (
78 <Button
79 variant="success"
80 onclick={() => toggleModifier(modifier)}
81 outline={!props.hotkey.includes(modifier)}

Callers

nothing calls this directly

Calls 4

createStylesFunction · 0.90
toggleModifierFunction · 0.85
getNonModifierValueFunction · 0.85
getDisplayHotkeyFunction · 0.85

Tested by

no test coverage detected