import { Chip } from '@mui/joy' import PropTypes from 'prop-types' /** * A component that displays keyboard shortcut hints as small chips * Only visible on non-mobile devices * Supports platform-specific shortcuts (Cmd on Mac, Ctrl on Windows) and Shift key */ function KeyboardShortcutHint({ shortcut, show = true, sx = {}, withCmd = true, // Legacy prop for backward compatibility withCtrl, withShift = false, ...props }) { if (!show) return null const isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0 const modifierKey = isMac ? '⌘' : 'Ctrl' // Build the shortcut display string let displayShortcut = '' // Support both withCmd and withCtrl for backward compatibility const shouldShowModifier = withCmd || withCtrl if (shouldShowModifier) { displayShortcut += modifierKey } if (withShift) { displayShortcut += (displayShortcut ? ' + ' : '') + 'Shift' } if (shortcut) { displayShortcut += (displayShortcut ? ' + ' : '') + shortcut } return ( {displayShortcut} ) } KeyboardShortcutHint.propTypes = { shortcut: PropTypes.string.isRequired, show: PropTypes.bool, withCmd: PropTypes.bool, withCtrl: PropTypes.bool, // Legacy prop for backward compatibility withShift: PropTypes.bool, sx: PropTypes.object, } export default KeyboardShortcutHint