Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

command-selector.tsx 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import type { FC } from 'react'
  2. import { Command } from 'cmdk'
  3. import { useTranslation } from 'react-i18next'
  4. import type { ActionItem } from './actions/types'
  5. type Props = {
  6. actions: Record<string, ActionItem>
  7. onCommandSelect: (commandKey: string) => void
  8. }
  9. const CommandSelector: FC<Props> = ({ actions, onCommandSelect }) => {
  10. const { t } = useTranslation()
  11. return (
  12. <div className="p-4">
  13. <div className="mb-3 text-left text-sm font-medium text-text-secondary">
  14. {t('app.gotoAnything.selectSearchType')}
  15. </div>
  16. <Command.Group className="space-y-1">
  17. {Object.values(actions).map(action => (
  18. <Command.Item
  19. key={action.key}
  20. value={action.shortcut}
  21. className="flex cursor-pointer items-center rounded-md
  22. p-2.5
  23. transition-all
  24. duration-150 hover:bg-state-base-hover aria-[selected=true]:bg-state-base-hover"
  25. onSelect={() => onCommandSelect(action.shortcut)}
  26. >
  27. <span className="min-w-[4.5rem] text-left font-mono text-xs text-text-tertiary">
  28. {action.shortcut}
  29. </span>
  30. <span className="ml-3 text-sm text-text-secondary">
  31. {(() => {
  32. const keyMap: Record<string, string> = {
  33. '@app': 'app.gotoAnything.actions.searchApplicationsDesc',
  34. '@plugin': 'app.gotoAnything.actions.searchPluginsDesc',
  35. '@knowledge': 'app.gotoAnything.actions.searchKnowledgeBasesDesc',
  36. '@node': 'app.gotoAnything.actions.searchWorkflowNodesDesc',
  37. }
  38. return t(keyMap[action.key])
  39. })()}
  40. </span>
  41. </Command.Item>
  42. ))}
  43. </Command.Group>
  44. </div>
  45. )
  46. }
  47. export default CommandSelector