list-page.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // @ts-nocheck
  2. import { RegistryDefinations } from '../types'
  3. /**
  4. * Shared shortcuts for "list pages" — the conventional Database/* page shape
  5. * with a schema selector, a search input, a primary "create new" action, and
  6. * one or more facet filters.
  7. *
  8. * Pages register their per-page handlers via `useShortcut`. Pass a `label`
  9. * override to make the Cmd+K entry and hover tooltip read e.g. "Search tables"
  10. * instead of the generic "Focus search" stored here.
  11. */
  12. export const LIST_PAGE_SHORTCUT_IDS = {
  13. LIST_PAGE_FOCUS_SCHEMA: 'list-page.focus-schema',
  14. LIST_PAGE_FOCUS_SEARCH: 'list-page.focus-search',
  15. LIST_PAGE_NEW_ITEM: 'list-page.new-item',
  16. LIST_PAGE_RESET_FILTERS: 'list-page.reset-filters',
  17. }
  18. export type ListPageShortcutId =
  19. (typeof LIST_PAGE_SHORTCUT_IDS)[keyof typeof LIST_PAGE_SHORTCUT_IDS]
  20. export const listPageRegistry: RegistryDefinations<ListPageShortcutId> = {
  21. [LIST_PAGE_SHORTCUT_IDS.LIST_PAGE_FOCUS_SCHEMA]: {
  22. id: LIST_PAGE_SHORTCUT_IDS.LIST_PAGE_FOCUS_SCHEMA,
  23. label: 'Open schema selector',
  24. sequence: ['O', 'S'],
  25. showInSettings: false,
  26. options: { ignoreInputs: true, registerInCommandMenu: true },
  27. },
  28. [LIST_PAGE_SHORTCUT_IDS.LIST_PAGE_FOCUS_SEARCH]: {
  29. id: LIST_PAGE_SHORTCUT_IDS.LIST_PAGE_FOCUS_SEARCH,
  30. label: 'Focus search',
  31. sequence: ['Shift+F'],
  32. showInSettings: false,
  33. options: { registerInCommandMenu: true },
  34. },
  35. [LIST_PAGE_SHORTCUT_IDS.LIST_PAGE_NEW_ITEM]: {
  36. id: LIST_PAGE_SHORTCUT_IDS.LIST_PAGE_NEW_ITEM,
  37. label: 'Create new item',
  38. sequence: ['Shift+N'],
  39. showInSettings: false,
  40. options: { registerInCommandMenu: true },
  41. },
  42. [LIST_PAGE_SHORTCUT_IDS.LIST_PAGE_RESET_FILTERS]: {
  43. id: LIST_PAGE_SHORTCUT_IDS.LIST_PAGE_RESET_FILTERS,
  44. label: 'Reset filters',
  45. sequence: ['F', 'C'],
  46. showInSettings: false,
  47. options: { ignoreInputs: true, registerInCommandMenu: true },
  48. },
  49. }