// Copyright (c) Meta Platforms, Inc. and affiliates. 'use client'; import {useRef, useState} from 'react'; import {Button} from '@astryxdesign/core/Button'; import {Card} from '@astryxdesign/core/Card'; import {Dialog, DialogHeader} from '@astryxdesign/core/Dialog'; import {useHotkeys} from '@astryxdesign/core/hooks'; import {Kbd} from '@astryxdesign/core/Kbd'; import { HStack, Layout, LayoutContent, StackItem, VStack, } from '@astryxdesign/core/Layout'; import {Switch} from '@astryxdesign/core/Switch'; import {Text} from '@astryxdesign/core/Text'; import {TextInput} from '@astryxdesign/core/TextInput'; export default function UseHotkeysHookUsage() { const searchRef = useRef(null); const [query, setQuery] = useState(''); const [isHelpOpen, setIsHelpOpen] = useState(false); // Single-character shortcuts need an off switch (WCAG 2.1.4). const [hasShortcuts, setHasShortcuts] = useState(true); useHotkeys([ { keys: '/', onPress: () => searchRef.current?.focus(), isDisabled: !hasShortcuts, }, { keys: '?', onPress: () => setIsHelpOpen(true), isDisabled: !hasShortcuts, }, ]); return (